Page 1 of 1

How to remove lines that start with a string?

Posted: Fri Jul 02, 2010 9:44 am
by benka
Hello

I have a text file:

Code: Select all

jkjfklgjdfslgj
jhdfkghdfkjs
zerjzeko
STRING1 gkmlkgmtlr
dfkljgsdlk
fgdkglmdf
gfdsjklm
fgd
STRING1 gdf4s56'"(_çà)à
STRING1 gkmlkgmtlr
dfkljgsdlk
fgdkglmdf
gfdsjklm
fgd
STRING1 ghfhgdf
How to delete all lines beginning with STRING1 ?

Thank you! :D

Posted: Fri Jul 02, 2010 10:01 am
by SteveH
You need to perform the following search and replace:

Find what:
^STRING1
With regular expression enabled and POSIX regular expression syntax enabled in the general preferences.

I'm assuming from your example that STRING1 does not vary and that it is always at the start of a line.The character '^' indicates the start of a line. Just leave the Replace with field empty.

Please note there is a space after '^STRING1'.

Hope this helps.

Posted: Fri Jul 02, 2010 10:11 am
by benka
Thank you for the reply.

But it does not work ... I use Textpad version 5.3.1 and I have POSIX enabled in preferences.

When I do a search and replace, only STRING1 disappears ... The rest of the line remains

Ideas?

Posted: Fri Jul 02, 2010 10:25 am
by ben_josephs
Find what: ^STRING1.*\n
Replace with: [nothing]

[X] Regular expression

Replace All

Posted: Fri Jul 02, 2010 10:32 am
by benka
ben_josephs wrote:
Find what: ^STRING1.*\n
Replace with: [nothing]

[X] Regular expression

Replace All
Still doesn't work... :-(

The STRING1 is "Nbre Destinataires Potentiels : "

Posted: Fri Jul 02, 2010 10:34 am
by benka
Sorry : it works!

Many thanks for all your help! :D