How can I query a specific number through regular expressions in mysql search? For example, if I want to query columns with 115 numbers in a field, but want to exclude 1115 or 11555555, does mysql support this query? How can I query a specific number through regular expressions in mysql search?
For example, if I want to query columns with 115 numbers in a field, but want to exclude 1115 or 11555555, does mysql support this query?
Reply content:
How can I query a specific number through regular expressions in mysql search?
For example, if I want to query columns with 115 numbers in a field, but want to exclude 1115 or 11555555, does mysql support this query?
Compared with the mysql manual, the script is ugly and cannot be written. \ D and (| [^ 0-9X]) are not found, and an error is also reported to me. Alas. mysql5.5.24
mysql> select '115' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+| 1 |+--------+1 row in set (0.00 sec)mysql> select '1150' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+| 0 |+--------+1 row in set (0.00 sec)mysql> select '11150' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+| 0 |+--------+1 row in set (0.00 sec)mysql> select 'a115a' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+| 1 |+--------+1 row in set (0.00 sec)
Not supported. The efficiency is too low and needs to be handled by yourself.
Yes, but the efficiency is not high.
SELECT mm, mm REGEXP '. Asterisk [^ 1] 115 [^ 5]. Asterisk $' FROM test.;