[英]REGEXP_SUBSTR Hex range in Oracle 11g and Oracle 12c
I am trying to check for certain invalid non-UTF8 characters. 我正在尝试检查某些无效的非UTF8字符。 From one of the post in this forum, I found this query:
从该论坛的一篇帖子中,我找到了以下查询:
SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle. 😊',
UNISTR('[\FFFF-\DBFF\DFFF]')) as str FROM dual;
Which gives the following output: 给出以下输出:
str
-------------------------------------------
😊
But the thing here is when I run the above query on Oracle 12c version, it works totally fine, but when I run the same on Oracle 11g(11.2.0.4) version, I get the following error: 但是这里的事情是当我在Oracle 12c版本上运行上述查询时,它完全可以正常工作,但是当我在Oracle 11g(11.2.0.4)版本上运行相同的查询时,出现以下错误:
ORA-12728: invalid range in regular expression
12728. 00000 - "invalid range in regular expression"
*Cause: An invalid range was found in the regular expression.
*Action: Ensure a valid range is being used.
Kindly provide your suggestions as to what is wrong that I am doing here. 请提供您关于我在这里做错了什么的建议。
Your range [XY]
in the pattern is wrong, since: 模式中的
[XY]
范围错误,原因是:
X= \\FFFF
is greater than Y= \\DBFF
(I don't know what \\DBFF\\DFFF
is supossed to do). X =
\\FFFF
大于Y = \\DBFF
(我不知道应该做什么\\DBFF\\DFFF
)。
By analogy - this regular expression [ab]
is right because a < b: 以此类推-这个正则表达式
[ab]
是正确的,因为a <b:
REGEXP_SUBSTR( 'some text', '[a-b]')
but this regular expression [ba]
is wrong because b > a: 但是这个正则表达式
[ba]
是错误的,因为b> a:
REGEXP_SUBSTR( 'some text', '[b-a]')
and you will get the same error in this case: 在这种情况下,您将得到相同的错误:
SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle.','[b-a]' ) FROM dual;
ORA-12728: invalid range in regular expression
---------- EDIT ---------- ----------编辑----------
But then why the query executes fine in 12c and gives an error in 11g?
但是,为什么查询在12c中执行正常并在11g中给出错误?
I am trying on Oracle 12.1.0.2.0, and get the same error 我正在Oracle 12.1.0.2.0上尝试,并得到相同的错误
SELECT * FROM V$VERSION;
SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle. 😊',
UNISTR('[\FFFF-\DBFF\DFFF]')) as str FROM dual;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for 64-bit Windows: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0
Error starting at line : 3 in command -
SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle. 😊',
UNISTR('[\FFFF-\DBFF\DFFF]')) as str FROM dual
Error report -
ORA-12728: invalid range in regular expression
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.