I can't figure out the proper regular expression for this... Most of my data ends with digits as the last two characters. A subset ends with where either one or both of the last two are non-digits. So xyz99 is normal and I'm able to find those records with "*[0-9][0-9]$"
. If I change that to "*[^0-9][^0-9]$"
then I get records where both are non-digits.
I don't know regex well enough to match all of the following with a single regex: xy9z, xyz9, xyzw, but not matching xyz99.
I prefer a single regex, but (already know how to and) can work-around with multiple.
Thanks for any help.
CodePudding user response:
[^\d]$|[^\d].$
should do the trick
CodePudding user response:
Thank you all for the quick and helpful responses. A couple of the references above that start with "(?"
are beyond what I understand so far. But the "or" operator is what I was missing. Here is what I ended up using (and it worked): select * from mytable where regexp_like( myfield, '.*([^0-9]|[^0-9][0-9])$' );