remove all junk characters from a file

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
flyinglow
Posts: 2
Joined: Wed Dec 19, 2007 8:34 pm

remove all junk characters from a file

Post by flyinglow »

I have file full of email and mailing addresses that has a lot of junk in the file that I need to remove. Is there anyway to remove all non-alpha, non-digit characters, but have some list of characters that are acceptable? For example, I don't want to remove '@' or '.' or '-' and I'm sure there are other characters that I can think of.

I guess I'm asking if I can find and replace all "junk" characters with some exceptions.

Thanks
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Does this do roughly what you want?
Find what: [^a-z0-9@._-]+
Replace with: [a space]

[X] Regular expression

Replace All
(The hyphen must be the last character (or the first character, after the negating ^) in the [^...] negated character class.)

Look in TextPad's help under
Reference Information | Regular Expressions.
flyinglow
Posts: 2
Joined: Wed Dec 19, 2007 8:34 pm

Post by flyinglow »

Thank you so much, that seems to be doing the trick. It appears to be skipping the '*' character. Is there any way I can include that as something I want to remove?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

The regular expression search and replace I suggested will replace with a single space every sequence of characters that aren't in the collection
a..z 0..9 @ . _ -
In particular, it will remove asterisks.

Please give an example of where you think it fails.
Post Reply