Hey I want to use a regular expression in MySQL to match rows. It needs to match rows where a the pattern ends with anything that's not a digit or the end of the line.
This pattern works in Ruby /download:223(?:[\D]|$)/
In MySQL it doesn't match. I'm guessing it doesn't allow for optional matching of eol.
SELECT id FROM stories WHERE body REGEXP 'download:223(?:[\D]|$)'
I need to match the following (quotes just for clarity):
"download:223"
"download:223*"
"download:223 something"
"download:223 more text"
But NOT the following (again quotes just for clarity):
"download:2234"
"download:2234 more text"
"download:2234*"
"download:2234* even more"
Thanks!
This regex should work for you:
"download:223([^0-9]|$)"
MySQL regex engine doesn't support \D, \d etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With