I'm trying to match all phones in a database which don't match with the format of this example '(11) 1234-5678'.
I'm having troubles defining a regexp because of the whitespace, I have done this tests:
SELECT '(11) 1234-5678' REGEXP "\([0-9]{2}\)" -> 1
SELECT '(11) 1234-5678' REGEXP "\([0-9]{2}\).*" -> 1
SELECT '(11) 1234-5678' REGEXP "\([0-9]{2}\) " -> 0
SELECT '(11) 1234-5678' REGEXP "\([0-9]{2}\)[:blank:]" -> 0
SELECT '(11) 1234-5678' REGEXP "\([0-9]{2}\)[:space:]" -> 0
I have absolutely no idea of why I can't get mysql to match a whitespace.
EDIT:
I'm using mysql 5.5.24
Use:
SELECT '(11) 1234-5678' REGEXP "\\([0-9]{2}\\)[[:space:]]"
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