I want to filter out those with field not like '%_[0-9]+'
,
but it turns out that MySQL doesn't take it as regex,
is that possible in MySQL?
Use the LIKE or NOT LIKE comparison operators instead. The other type of pattern matching provided by MySQL uses extended regular expressions. When you test for a match for this type of pattern, use the REGEXP_LIKE() function (or the REGEXP or RLIKE operators, which are synonyms for REGEXP_LIKE() ).
If you want to match for the actual '+', '. ' etc characters, add a backslash( \ ) before that character. This will tell the computer to treat the following character as a search character and consider it for matching pattern. Example : \d+[\+-x\*]\d+ will match patterns like "2+2" and "3*9" in "(2+2) * 3*9".
You can use RegEx in many languages like PHP, Python, and also SQL.
That happens because of LIKE is not supposed to accept regular expression as a parameter. There is REGEXP for such things
WHERE field NOT REGEXP '%_[0-9]+'
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