regular expression help

General questions about using TextPad

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

Post Reply
dabombst
Posts: 11
Joined: Tue Nov 01, 2005 7:24 pm

regular expression help

Post by dabombst »

Hi

I need to delete from the "\" to the ";", but dont want the semicolon to be delete.

Export002\AIG 005647-AIG 005647;AIG 005647-AIG 005647.T
Export00200\AIG 005648-AIG 005648;AIG 005648-AIG 005648.T
Export0022\AIG 005649-AIG 005649;AIG 005649-AIG 005649.T

to look like this...

Export002;AIG 005647-AIG 005647.T
Export00200;AIG 005648-AIG 005648.T
Export0022;AIG 005649-AIG 005649.T

thanks
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post by SteveH »

You need to use the following regular expression:

Find:
\\.*;
Replace with:
;
This finds instances of \ (the initial \ escape character makes this a literal backslash) followed by any character (.) repeated (*) and followed by a ;. This string is replaced with a ;
dabombst
Posts: 11
Joined: Tue Nov 01, 2005 7:24 pm

Post by dabombst »

thanks
User avatar
Niels H. Veldhuijzen
Posts: 15
Joined: Mon Apr 19, 2004 12:12 pm
Location: Zutphen, The Netherlands
Contact:

Post by Niels H. Veldhuijzen »

Dear SteveH,

Are you sure this will work when there are two or more semicolons in one line? :(
Yours sincerely,

Niels H. Veldhuijzen
Zutphen, The Netherlands
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

If you want to delete from the first '\' to the first ';' following, use:
Find what: \\[^;]*;
Replace with: ;

[X] Regular expression
Post Reply