Regular expression to change line of text

General questions about using TextPad

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

Post Reply
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Regular expression to change line of text

Post by dforrest »

Can someone please help me with a regular expression to change multiple instances of:

FileName ( ../../Routes/Watersnake/Alias/xyz1234.s )

in a file to:

FileName ( "../../Routes/Watersnake/Alias/xyz1234.s" )

xyz1234 is different in content and length in each expression and should remain unchanged. The remainder is the same in all expressions and should be repeated as it is.

Thank you.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Depending the exact details of what is to be replaced, this might do it:

Find what: FileName \( ([^)]+) \)
Replace with: FileName \( "$1" \)
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

ben_josephs wrote:Depending the exact details of what is to be replaced, this might do it:

Find what: FileName \( ([^)]+) \)
Replace with: FileName \( "$1" \)
Thanks but it adds the quotes for all lines with a format like

FileName ( xxxxx.s )

I really only need to replace lines with ../../Routes/Watersnake/Alias included in them.

If that is not possible, what you have provided should be acceptable.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: FileName \( (\.\./\.\./Routes/Watersnake/Alias/[^)]+) \)
Replace with: FileName \( "$1" \)
dforrest
Posts: 44
Joined: Mon Jan 19, 2004 11:19 pm
Location: St. Vincent and the Grenadines

Post by dforrest »

ben_josephs wrote:Find what: FileName \( (\.\./\.\./Routes/Watersnake/Alias/[^)]+) \)
Replace with: FileName \( "$1" \)
Thanks Ben. This is just what I needed.
Post Reply