Page 1 of 1

600 expressions

Posted: Mon Feb 18, 2008 8:28 pm
by chrisjj
I have 600 one-line regexps and corresponding replacementpatterns which I need to apply to about 100 files. How to I do this? I seem unable to get Replace to recognise the 600 lines as separate expressions.

Thanks.

Posted: Mon Feb 18, 2008 10:57 pm
by ben_josephs
I presume you selected the option Syntax options: Newline separates alternatives.
Try selecting the option Literal line break characters: Linefeed only (Unix), too.
Or you can separate the alternatives with a | on a single line.

How are you going to apply the corresponding replacements correctly? By using conditional expressions?

Posted: Mon Feb 18, 2008 11:05 pm
by chrisjj
> How are you going to apply the corresponding replacements correctly?

Put the 600 lines the "Replace with:"?

Posted: Tue Feb 19, 2008 9:03 am
by ben_josephs
What do you mean by corresponding? Do you mean that if the first regular expression matches then the first replacement expression should be used, and so on? If so, you can't just put the replacement expressions on separate lines. What you need is conditional expressions. For example:
Find what: (a)|(b)|(c)|(d)|(e)|(f)|(g)|(h)|(i)|(j)|(k)|(l)|(m)|(n)|(o)|(p)|(q)|(r)|(s)|(t)|(u)|(v)|(w)|(x)|(y)|(z)
Replace with: ?1(Alpha ):?2(Bravo ):?3(Charlie ):?4(Delta ):?5(Echo ):?6(Foxtrot ):?7(Golf ):?8(Hotel ):?9(India ):?10(Juliet ):?11(Kilo ):?12(Lima ):?13(Mike ):?14(November ):?15(Oscar ):?16(Papa ):?17(Quebec ):?18(Romeo ):?19(Sierra ):?20(Tango ):?21(Uniform ):?22(Victor ):?23(Whisky ):?24(X-ray ):?25(Yankee ):?26(Zulu )

[X] Regular expression
[X] Replacement format
Of course, you'll need to use TextPad to create your regular and replacement expressions...

Posted: Tue Feb 19, 2008 10:09 am
by chrisjj
> Do you mean that if the first regular expression matches
> then the first replacement expression should be used, and so on?

Yup.

> What you need is conditional expressions.

Oh dear!

> Of course, you'll need to use TextPad to create
> your regular and replacement expressions...

Why is TextPad needed?

Posted: Tue Feb 19, 2008 10:48 am
by ben_josephs
chrisjj wrote:Why is TextPad needed?
I wouldn't like to construct a regular expression and replacement expression like those I suggested above with 600 elements in each without a decent editor.

Posted: Tue Feb 19, 2008 11:23 am
by chrisjj
I have a decent editor (not TextPad), thanks.

Can anyone suggest an alternative to WE that will directly accept 600 regexp-replacement pairs? Thanks.

Posted: Wed Feb 20, 2008 8:50 am
by agnul

Posted: Wed Feb 20, 2008 11:35 am
by chrisjj
Ho ho ;)