Need Help With Filtering

A place to try and solve your RegEx problems.
Post Reply
User avatar
Darren

Need Help With Filtering

Post by Darren »

Looking throug the various parameters for filtering searches, I'm having trouble understand this, so I'll ask here...

Looking for two situations:

1) Would like to find lines with a given word
but, don't want those listed that this word is part of another word
i.e. Find all lines that contain word BETH
BUT, don't want lines with word ELIZABETH (or BETHLEHEM, etc.)

2. Looking for all lines that contain a word, but don't want list to include lines if this word if part of either of two variations of another word
i.e. STAGE
But don't include SOUNDSTAGE and SOUND STAGE

Hope what I'm trying to ask makes sense...

Thank you!!
User avatar
DV

Post by DV »

Your first example can be done using the whole word only switch - \b

eg: \bbeth\b

Example 2 is more complicated - it might require something like this - http://bloggingabout.net/blogs/arjen/ar ... -word.aspx



User avatar
Bill S

Post by Bill S »

I am tring to find and replace the following string:
DB_CP_HIST_EXTR_AXIS2_AV 450

And replace it with:
DB_CP_HIST_EXTR_AXIS2_AV 500

The problem is that there may be more characters after the 500 that need to be erased during the replace. Is there a command to add to the replace to erase everything else in the line you are replacing?
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

Erasing could be done by replacing something with nothing.

So, you could extend your regular expression to match "anything" behind the 450 as well.

If you add .*$ and do not change the Replace text, "anything" will not be re-placed, so in effect will be removed.

Find:
DB_CP_HIST_EXTR_AXIS2_AV 450.*$

Replace:
DB_CP_HIST_EXTR_AXIS2_AV 500
User avatar
Bill S

Post by Bill S »

I tried the .*$ and it did not work. But it may have been my fault. The find statement is looking for 3 digits so I used:
DB_CP_HIST_EXTR_AXIS2_AV (\d[3])

The line that I am doing a find on contains a number that could be anything from 0 - 999 and I need to replace it with a specific number like 500. I also need to be sure the rest of the line is blank. Thank you for your help so far but maybe I am not doing the find correctly.
User avatar
Bill S

Post by Bill S »

This is and addition to the previous post sept 30, in the find statement:
DB_CP_HIST_EXTR_AXIS2_AV << this space may very >> (\d[3])
User avatar
Bill S

Post by Bill S »

Related to the posting above. Once the find statement finds the numbers to be replaced. The replace numbers have to go in the same position the find numbers were located.

Thank you
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

Perhaps this will work.

Find:
DB_CP_HIST_EXTR_AXIS2_AV (\d{3}).*$

Replace with:
DB_CP_HIST_EXTR_AXIS2_AV $1

[3] means: find one of the characters listed between [ and ]
{3} means: match the preceding expression exactly 3 times

$1 means: re-place the first () grouped match
Post Reply