[英]Extracting phone numbers from a string using sql
Actually I want to catch the phone numbers in a string.其实我想在一个字符串中捕捉电话号码。 On some websites its mentioned that use this Regexpression ( ref )在一些网站上它提到使用这个 Regexpression ( ref )
^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$
But it's not working on the normal sql query.但它不适用于普通的 sql 查询。 Here's the syntax:这是语法:
REGEXP_LIKE (mystring, '^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$')
I am doing something wrong here ?我在这里做错了什么?
\\d and \\s don't exist in MySQL. \\d 和 \\s 在 MySQL 中不存在。 Use [[:digit:]]
or [0-9]
and [[:space:]]
or [[:blank:]]
or simply使用[[:digit:]]
或[0-9]
和[[:space:]]
或[[:blank:]]
或干脆. .
Some other things are fixed here:其他一些事情在这里得到修复:
str REGEXP '^([+][0-9]{1,2})?([(][0-9]{3}[)]|[0-9]{3})[-. ][0-9]{4}$'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.