Oracle Regex替换负面预测(Oracle Regex Replace negative lookahead)

系统教程 行业动态 更新时间:2024-06-14 16:57:17
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')

更多推荐

本文发布于:2023-04-12 20:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/6a4cf78439e0e8f07261bdcf8a2de82d.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:负面   Regex   Oracle   lookahead   negative

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!