Oracle Regex替换负面预测(Oracle Regex Replace negative lookahead)
我正在编写一些正则表达式+查询以匹配美国电话号码。 具有负前瞻的下一个从正则表达式角度进行验证,但由于不支持负前瞻而在Oracle中不起作用。 任何人都可以帮我修改查询以在Oracle中工作吗?
select 'match' from dual WHERE REGEXP_LIKE('16665555555', '^1?(?!911)[2-9][0-9]{9}$');它不会为oracle中的任何数字返回匹配项。
谢谢,安迪
I'm writing some regex + queries to match US phone numbers. The one below with negative lookahead gets validated from a regex perspective, but doesn't work in Oracle due to negative lookahead not being supported. Can anyone please help me modify the query to work in Oracle?
select 'match' from dual WHERE REGEXP_LIKE('16665555555', '^1?(?!911)[2-9][0-9]{9}$');It doesn't return a match for any number in oracle.
Thanks, Andy
最满意答案
WHERE REGEXP_LIKE(phone, '^1?[2-9]\d{9}$') and not REGEXP_LIKE(phone, '^1?911') WHERE REGEXP_LIKE(phone, '^1?[2-9]\d{9}$') and not REGEXP_LIKE(phone, '^1?911')更多推荐
发布评论