Reputation: 23
How to regex match words that have digits or any non-characters inside words, excluding when digits and non-characters (\/°†@*()'\s+&;±|-\^
) are at the end of word? I need to match dAS2a
but not dASI6
. Could not adapt the Regex to match string not ending with pattern solution.
dA/Sa
dAS2a
dASI/
dASI6
http://regex101.com/r/qM4dV7/1 failed.
Upvotes: 0
Views: 321
Reputation: 20486
This should work just fine (if you use the gmi
modifiers):
^.*[a-z]$
You said each word is on a new line. Using the m
modifier we can anchor each expression to the beginning/end of a line with ^
and $
anchors (without the modifier, this means beginning/end of the string). Then you said a word can essentially be anything (.*
) as long as it ends in a non-digit or non-special character (I took that to mean a "letter", [a-z]
with the i
modifier).
Upvotes: 1