[英]REGEXP_SUBSTR Hex range in Oracle 11g and Oracle 12c
我正在嘗試檢查某些無效的非UTF8字符。 從該論壇的一篇帖子中,我找到了以下查詢:
SELECT REGEXP_SUBSTR('This will be my first time visiting Seattle. 😊',
UNISTR('[\FFFF-\DBFF\DFFF]')) 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.
請提供您關於我在這里做錯了什么的建議。
模式中的[XY]
范圍錯誤,原因是:
X = \\FFFF
大於Y = \\DBFF
(我不知道應該做什么\\DBFF\\DFFF
)。
以此類推-這個正則表達式[ab]
是正確的,因為a <b:
REGEXP_SUBSTR( 'some text', '[a-b]')
但是這個正則表達式[ba]
是錯誤的,因為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-\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.