SOLVED [thelist] Escaping Parenthesis in RegExp

Robert Goodyear rob_goodyear at yahoo.com
Sun Mar 10 01:12:01 CST 2002


Thanks Chris. After a day of surfing and digging through UltraEdit's forum, I
decided that UE's implementation of RegExp is flawed in combining escaped
characters and tagged expressions. Causes it to fail.

I came to the same solution too, by reverting UE back to Unix-style RegExp,
which handles tagging via ( ) while escaping with \( without a problem.

Thanks!

-Robert Goodyear

--- Chris Spruck <cspruck at mindspring.com> wrote:
> At 09:35 PM 3/8/02 -0800, Robert Goodyear wrote:
> >In UltraEdit's RegExp syntax, the ^ is used to escape, but when using tagged
> >expressions it all goes haywire, for example in the following string,
> >
> >This is a test of (123) in a replacement.
> >
> >If I want to change "(123)" to "Number:123", the RegExp...
> >
> >Find: ^(^(???^)^)
> >Replace: Number:^1
> >
> >...completely blows up. I've tried using the backslash for escaping, too,
> and
> >that doesn't work. I believe the Tagged Expressions are what's causing the
> >problem, as UE uses ^( and ^) to delimit a tagged exp, which is identical to
> >what an escaped special character should look like.
> >
> >-Robert Goodyear
>
> Robert,
>
> I took a look at UltraEdit since I had a local copy and found an option
> which will help make this a LOT easier. Go to the Advanced menu, select
> Configuration, click the Find tab, and check the checkbox for Unix style
> Regular Expressions. Even with doing that, UE seems to have an incomplete
> implementation of regex, so check out the help from the find dialog for all
> the operators and some examples.
>
> This expression    \((\d\d\d)\)    will find your string and you can then
> replace it with Number:\1.
>
> The \ escapes the ( around your number, then the second ( is what groups
> for the replace backreference. The \d grabs any single digit, (so you need
> three of \d, since UE regex doesn't let you define the number of instances
> you want any other way), then the ) closes the replace backreference, then
> \) closes the ) around your number.
>
> Hope this helped!
>
> Chris


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/



More information about the thelist mailing list