Problem with regular expression not being restrictive enough

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
johnbweb
Posts: 10
Joined: Wed May 18, 2005 3:04 pm

Problem with regular expression not being restrictive enough

Post 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.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post 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)"
johnbweb
Posts: 10
Joined: Wed May 18, 2005 3:04 pm

Post by johnbweb »

The very thing!

Thanks,
John B.
Post Reply