RegEx find using \1 across 1 or more lines
Posted: Wed Nov 19, 2003 5:02 pm
Using POSIX compliant setting, I am able to find multiple instances of a given item within a line by the use of () and \1, but if I attempt to do this across multiple lines (by adding $ or \n in, as appropriate) it does not seem to work. For example:
SAMPLE TEXT:
A treeefaaall creates an opeeening.
But threee trees remain.
Find within line:
([aeiou]{3})[^\1]+\1
This works as expected, and finds the 2x eee in the first line.
Find across lines, version a:
([aeiou]{3})[^\1]+\n[^\1]+\1
This is reported as an "Invalid regular expression"...
Find across lines, version b:
([aeiou]{3})[^\1]+$[^\1]+\1
This does not generate an error message, but it does not find the expected text.
Is there a way to effectively find multiple instances of the same string across multiple lines without "hard-coding" them into the find expression repeatedly?
THANKS!!
Dave
SAMPLE TEXT:
A treeefaaall creates an opeeening.
But threee trees remain.
Find within line:
([aeiou]{3})[^\1]+\1
This works as expected, and finds the 2x eee in the first line.
Find across lines, version a:
([aeiou]{3})[^\1]+\n[^\1]+\1
This is reported as an "Invalid regular expression"...
Find across lines, version b:
([aeiou]{3})[^\1]+$[^\1]+\1
This does not generate an error message, but it does not find the expected text.
Is there a way to effectively find multiple instances of the same string across multiple lines without "hard-coding" them into the find expression repeatedly?
THANKS!!
Dave