Finding non text characters in a list

General questions about using TextPad

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

Post Reply
burtonfigg
Posts: 11
Joined: Wed Jun 01, 2005 6:37 pm

Finding non text characters in a list

Post by burtonfigg »

I have a big list of text values - e.g.:

thisismyname
andsomething
elselikethat
and(some)contain
other-characters

Is it possible to use a regular expression to identify any lines which contain anything other than just standard 1-9 and a-z characters?

Thanks

Jim
daveok
Posts: 1
Joined: Sat May 17, 2008 2:43 pm

Post by daveok »

You need to search for anything that doesn't fit into a list of specific characters, so you use a character class match, and negate it.

To match one or more alphanumeric chars,

Code: Select all

[0-9a-zA-Z]+
To match one or more non-alphanumeric chars,

Code: Select all

[^0-9a-zA-Z]+
Put that code into the textpad search, enable regex, then click mark all and it'll mark every line that has a non-alphanumeric character in it.

If you wanna use a regex to delete all lines that contain non-alphanumerics, use this regex and leave the replace with field empty.

Code: Select all

^.*[^0-9a-zA-Z]+.*$\n?
It matches the following, in order:
start of line
any number of any characters
one or more characters that are not alphanumeric
any number of any characters
end of line
zero or one of a newline character

I have posix regex turned OFF in my TP settings. If you want to allow dashes in your strings, change the character class to include it:

Code: Select all

[^0-9a-zA-Z-]+
Post Reply