Delete lines starting with # in selected text

General questions about using TextPad

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

Post Reply
acessn
Posts: 10
Joined: Thu Jul 06, 2006 12:20 pm

Delete lines starting with # in selected text

Post by acessn »

Hi.

I'd like to delete all lines starting with # within selected text.

Code: Select all

# Delete me
Keep me
#Delete me
Keep me

Would end up with 

Keep me
Keep me
I've tried find: ^#$
Replaced with "" but there's something wrong with the regular expression.

Thanks,

Bjorn
acessn
Posts: 10
Joined: Thu Jul 06, 2006 12:20 pm

I've got it

Post by acessn »

with

Code: Select all

^# .*$
Replaced with nothing
acessn
Posts: 10
Joined: Thu Jul 06, 2006 12:20 pm

Another issue has come up...

Post by acessn »

How do I delete blank lines?

Code: Select all

Line1

Line 2

Line3

Should be 

Line1
Line2
Line3

Thanks,

Bjorn
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Re: I've got it

Post by ben_josephs »

acessn wrote:

Code: Select all

^# .*$
This should be

Code: Select all

^#.*$
(no space) to avoid missing

Code: Select all

#Delete me
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

To delete blank lines:
Find what: ^\n
Replace with: [Nothing]

[X] Regular expression
acessn
Posts: 10
Joined: Thu Jul 06, 2006 12:20 pm

Post by acessn »

Great!

Thanks a lot.

-Bjorn
Post Reply