Page 1 of 1

What am I missing here?

Posted: Fri Apr 06, 2012 9:51 am
by terrypin
I've been trying for an hour or more to find out why the following doesn't work. It's going to be something emabarrasingly obvious!

To take the simplest example, suppose I have 2 lines of text
abc
xyz

This works OK as the Find target:
abc\nxyz

But when I use
(abc\nxyz)
as a step towards writing a replacement expression, I get an error:
Unmatched '( or {'

Same with other similar combinations.

What is 'unmatched' please?

--
Terry, East Grinstead, UK

Posted: Fri Apr 06, 2012 2:00 pm
by ben_josephs
The way TextPad's regex recogniser handles newlines is very weak. It doesn't allow a \n to be quantified with * or + or {m,n}, or (the one relevant to your example) to be contained in a parenthesised expression. It also doesn't allow a back-reference to refer back over a newline.

Posted: Fri Apr 06, 2012 2:21 pm
by terrypin
Thanks, that's been bugging me all day!

I've now successfully used the following, keeping the \n free of parentheses:

Find (<LabelStyle>)\n([ ]+<scale>)(.*)(</scale>)
Replace with: \1\n\22.0\4

If you're curious, it's for use on the KML of a folder pasted into TextPad from Google earth, and makes all label styles size 2.0

I suppose I should have used WildEdit, but I'm so familiar with Textpad's Regex. Pity it's not so hot on this sort of 'multiple line' stuff.

--
Terry, East Grinstead, UK