trembling trembling - 1 year ago 174
MySQL Question

mysql REGEXP not matching

I have a regular expression intended to catch phone numbers within a string

/[1,+ ().-][\s.-]\d{3}[\s.-]\d{3}[\s.-]\d{4}/

I try to query my MySql database for this regex using this query:

`everything`.`instances_meta` AS m
`meta.value` REGEXP "[1,+][\s.-]\d{3}[\s.-]\d{3}[\s.-]\d{4}"

I can confirm the regex, itself, does what I want from testing it here but it does not pull any matches when queried. Something tells me I am missing some sort of expression to say "anywhere in the string". I would specify the regex engine but I am unsure of what MySql uses.

Answer Source



as MySQL REGEXP does not support \s and \d.

The [:blank:] matches spaces and tabs, and [0-9] matches any ASCII digit.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download