find, copy, replace then insert -- help needed

General questions about using WildEdit

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

Post Reply
jahmus
Posts: 1
Joined: Sat Jan 12, 2008 4:07 am

find, copy, replace then insert -- help needed

Post by jahmus »

I would like to find a line that begins with a variable number of spaces and\or tabs, contains a known string and ends with a variable number of spaces and\or tabs and then a slash

Line to find:

xxx9.lib \

Then replace part of the string (9) with (9_1) and insert it after the orignal string with the same leading spaces and\or tabs.

Result:

xxx9.lib \
xxx9_1.lib \

Any help would be apperciated, particularlly around the replacement part.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

I'll use _ to mark a space in the search expression. The _ in the replacement is a real _ ;-)

Line beginning: ^
variable number of spaces or tabs, even zero: [_\t]*
Backslash (needs to be escaped, otherwise it would escape the following character!): \\
Line end: $
you want to keep some parts so remember them by putting () around them
in the replace value use \1, \2, \3 ... for the remembered parts

This will result in

Search for:

Code: Select all

^([_\t]*xxx9)(.lib[_\t]*\\)$
Replace by

Code: Select all

\1_1\2
Last edited by MudGuard on Sat Jan 12, 2008 1:25 pm, edited 1 time in total.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

That's the TextPad way; it won't work in WildEdit, which uses Perlish regular expressions, which are far more powerful.

You need something like
Find what: ^(\s*)9\.lib(\s*\\)
Replace with: $1(9_1.lib)$2

[X] Regular expression
[X] Replacement format
Post Reply