Page 1 of 1
Using regular expressions to remove lines
Posted: Sun Jan 06, 2002 4:58 pm
by Stefan
I want to use regular expressions to delete a full text line, but only the textlines which ends with a certain textstring.
for instance, I want to remove all lines endng with ".txt"
insert in the find and replace dialog:
find what: ".txt$"
replace with: ...
can anyone help me out?
Thanks
Re: Using regular expressions to remove lines
Posted: Sun Jan 06, 2002 8:13 pm
by Stephan
You could use search (check the regular expression check box), and then click 'Mark All' - CRTL-D B will then delete all marked lines.
Help that helpped,
StePhan
Re: Using regular expressions to remove lines
Posted: Mon Jan 07, 2002 8:25 am
by Jens Hollmann
There is a search-replace-solution:
Search: ^.*\.txt\n
Replace with nothing
Regular expressions have to be turned on!.
^ Matches the beginning of a line
.* matches any character (even none) but not newline
\.txt matches the literal text ".txt". The "\" before the "." is necessary because a "." matches any single character when regular expressions are on
\n finally matches the newline
Hope that helps
Jens
Re: Using regular expressions to remove lines
Posted: Sat Jan 12, 2002 6:58 pm
by Stefan
Thanks guys, both solutions worked!
Jens' solutions was the one I was looking for.
But Stephans solution was a nice suprise to me! Thanks Stephan, as a novice user of TextPad I didn't noticed the Mark function in the Find dialog before.
TextPad keeps surprising me, and until now alway positive!