Page 1 of 1

Problem with regular expression not being restrictive enough

Posted: Tue Sep 25, 2007 1:50 pm
by johnbweb
Hi,

I'm having problem with using regular expressions in TextPad. Normally, TextPad handles regular expressions with remarkable accuracy. However, in this case, there seems to be a problem.
Find:
Long Value="8685\|8720\|8710\|9305\|8715\|8640\|8645\|9290\|9265\|9275\|9280\|9300\|9285\|9295"

For some reason, TextPad is only matching the numbers in the find string, and is not matching the "Long Value=" part of the find string. So for example, it matches both:
<NameValue Name="211D0324093058">
<Long Value="9305"/>

When what I really want it to match is only:
<Long Value="9305"/>

I've tried escaping the quotes with a backslash, but it doesn't seem to make any difference. "POSIX regular expression syntax" is not checked in the Options.

Thanks,
John B.

Posted: Tue Sep 25, 2007 1:56 pm
by ben_josephs
You need some parentheses in there:
Long Value="\(8685\|8720\|8710\|9305\|8715\|8640\|8645\|9290\|9265\|9275\|9280\|9300\|9285\|9295\)"

In Posix syntax, it's rather more readable:
Long Value="(8685|8720|8710|9305|8715|8640|8645|9290|9265|9275|9280|9300|9285|9295)"

Posted: Tue Sep 25, 2007 3:31 pm
by johnbweb
The very thing!

Thanks,
John B.