开发者

Oracle regex: \Q\E doesn't work

I found that \Q\E doesn't work in ora开发者_如何学运维cle.

What is the equivalent expression of \Q\E for oracle regex ?


In Perl, \Q starts the automatic escaping of special characters and \E stops this behaviour. So within a \Q \E block, a dot would be treated as a literal dot rather than any character.

If Oracle doesn't support this, then just escape any special characters that would have been in the block.


This is an old question, but with Java you can do

Pattern.quote(yourString);

which returns a literal string. So the String . would return \Q.\E, which would be considered a period by the Matcher.


This is old, but still an issue in Oracle Database 11g Release 11.2.0.1.0, and I don't see it addressed elsewhere. So, in case it helps others, my solution is:

select dummy from dual where REGEXP_LIKE(dummy,REGEXP_REPLACE('X','([]\^.$|()[*+?{},])','\\\1'))

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜