What am I missing here?

General questions about using TextPad

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

Post Reply
terrypin
Posts: 174
Joined: Wed Jul 11, 2007 7:50 am

What am I missing here?

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

Post 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.
terrypin
Posts: 174
Joined: Wed Jul 11, 2007 7:50 am

Post 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
Post Reply