REGEXP_SUBSTR Oracle 11g 和 Oracle 12c 中的十六进制范围



我正在尝试检查某些无效的非UTF8字符。从这个论坛的一篇文章中,我发现了这个查询:

SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle. 😊',
UNISTR('[FFFF-DBFFDFFF]')) as str FROM dual;

这给出了以下输出:

str
-------------------------------------------
😊

但是这里的问题是,当我在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.

请就我在这里做错什么提供您的建议。

模式中的范围[X-Y]是错误的,因为:
X=FFFF大于 Y=DBFF(我不知道DBFFDFFF要做什么(。

通过类比 - 这个正则表达式[a-b]是正确的,因为 a <b:>

REGEXP_SUBSTR( 'some text', '[a-b]')

但是这个正则表达式[b-a]是错误的,因为 B> a:

REGEXP_SUBSTR( 'some text', '[b-a]')

在这种情况下,您将获得相同的错误:

SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle.','[b-a]' ) FROM dual;
ORA-12728: invalid range in regular expression

---------- 编辑 ----------

但是,为什么查询在 12c 中执行正常并在 11g 中给出错误?

我正在尝试使用 Oracle 12.1.0.2.0,但收到相同的错误

SELECT * FROM V$VERSION;
SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle. 😊',
UNISTR('[FFFF-DBFFDFFF]')) 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-DBFFDFFF]')) as str FROM dual
Error report -
ORA-12728: invalid range in regular expression

最新更新