How to remove lines that start with a string?

General questions about using TextPad

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

Post Reply
benka
Posts: 4
Joined: Fri Jul 02, 2010 9:41 am

How to remove lines that start with a string?

Post 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
User avatar
SteveH
Posts: 327
Joined: Thu Apr 03, 2003 11:37 am
Location: Edinburgh, Scotland
Contact:

Post 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.
Running TextPad 5.4 on Windows XP SP3 and on OS X 10.7 under VMWare or Crossover.
benka
Posts: 4
Joined: Fri Jul 02, 2010 9:41 am

Post 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?
ben_josephs
Posts: 2459
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: ^STRING1.*\n
Replace with: [nothing]

[X] Regular expression

Replace All
benka
Posts: 4
Joined: Fri Jul 02, 2010 9:41 am

Post 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 : "
benka
Posts: 4
Joined: Fri Jul 02, 2010 9:41 am

Post by benka »

Sorry : it works!

Many thanks for all your help! :D
Post Reply