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
Finding non text characters in a list
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
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,
To match one or more non-alphanumeric chars,
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.
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:
To match one or more alphanumeric chars,
Code: Select all
[0-9a-zA-Z]+
Code: Select all
[^0-9a-zA-Z]+
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?
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-]+