Hi, I have file with a few thousands lines of text. Each line contains a match to the following regular expression:
("................")
I want to delete all characters before & after the regular expression, leaving me with only the characters matching the regular express (one match per line). Is this possible? The number of characters before & after vary from line to line.
Thanks!
*** UPDATE ***
I figured out how to find what I need
.*("................")
OR
("................").*
Now I just need to figure out how to do a replace that preserves the ("................"). Obviously this doesn't work:
FIND: .*("................")
REPLACE: ("................")
How do I replace to preserve the original characters matching ("................")?
Delete before & after
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
From HELP on Regular Expressions:
Using the \1 or \2 or \3 as an example will replace the first, second, and third groups of (characters) in parenthesis.
Expression Definition
& Substitute the text matching the entire search pattern.
\0 to \9 Substitute the text matching tagged expression 0 through 9. \0 is equivalent to &.
---------------------------------------
Using the \1 or \2 or \3 as an example will replace the first, second, and third groups of (characters) in parenthesis.
Search for: *.(xxxxxxx)
Replace with: \1
Will result with xxxxxxx
Search for (aaaaa).*(bbbbb)
Replace with: \2-\1
Will result with bbbbb-aaaaa
Search for: (abc).*(def)([0-9]{3})
Replace with: \2\3
Will result in def followed by 3 digits.
Using the \1 or \2 or \3 as an example will replace the first, second, and third groups of (characters) in parenthesis.
Expression Definition
& Substitute the text matching the entire search pattern.
\0 to \9 Substitute the text matching tagged expression 0 through 9. \0 is equivalent to &.
---------------------------------------
Using the \1 or \2 or \3 as an example will replace the first, second, and third groups of (characters) in parenthesis.
Search for: *.(xxxxxxx)
Replace with: \1
Will result with xxxxxxx
Search for (aaaaa).*(bbbbb)
Replace with: \2-\1
Will result with bbbbb-aaaaa
Search for: (abc).*(def)([0-9]{3})
Replace with: \2\3
Will result in def followed by 3 digits.
Hope this was helpful.............good luck,
Bob
Bob