PL/SQL Oracle 正则表达式对于出现零的情况不起作用
我在 Oracle PL/SQL 中匹配正则表达式时遇到问题。 更具体地说,问题是正则表达式不想匹配任何零出现。 例如,我有类似的东西:
select * from dual where regexp_like('', '[[:alpha:]]*');
但这不起作用。但如果我在这句话中留出空间:
select * from dual where regexp_like(' ', '[[:alpha:]]*');
它有效。
我想让第一个示例运行,这样那个人就不必为其工作添加“空间”。 感谢您的帮助,并感谢您的宝贵时间。
时间
I have a problem in matching regular expression in Oracle PL/SQL.
To be more specific, the problem is that regex doesn't want to match any zero occurrence.
For example, I have something like:
select * from dual where regexp_like('', '[[:alpha:]]*');
and this doesn't work. But if I put space in this statement:
select * from dual where regexp_like(' ', '[[:alpha:]]*');
it works.
I want to have the first example running, so that person doesn't have to put 'space' for it to work.
Any help is appreciated, and thank you for your time.
T
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于更好或更坏,空字符串Oracle 被视为 NULL:
使用 Oracle 查询时请考虑到这一点:
For better or worse, empty strings in Oracle are treated as NULL:
Take that into account when querying with Oracle:
Oracle 仍然将空字符串视为 NULL 吗?如果是这样,带有 NULL 输入源字符串的 regexp_like 是否返回 UNKNOWN?这两者都是半合理的,也是您的测试未按预期进行的原因。
Does Oracle still treat empty strings as NULLs? And if so, does regexp_like with a NULL input source string return UNKNOWN? Both of these would be semi-reasonable, and a reason why your test does not work as you expected.