Oracle REGEXP
REGEXP_LIKE
REGEXP_SUBSTR
REGEXP_INSTR
REGEXP_REPLACE[@more@]====================
REGEXP_LIKE
====================
SQL> select * from t1;
COL1 COL2
---------- ----------
1 fly
2 flying
3 swim
4 Fly
5 Flies
SQL> select * from t1 where regexp_like(col2, 'fl(y(ing)?|(ies))');
COL1 COL2
---------- ----------
1 fly
2 flying
--'i' => 不區分大小寫
SQL> select * from t1 where regexp_like(col2, 'fl(y(ing)?|(ies))','i');
COL1 COL2
---------- ----------
1 fly
2 flying
4 Fly
5 Flies
====================
REGEXP_SUBSTR
====================
REGEXP_SUBSTR(source_char,pattern,position,occurrence,match_parameter)
source_char=>源字串
pattern=>正規表示式
position=>從source_char的第幾個字元開始搜尋,預設值1
occurrence=>返回第幾次匹配結果,預設值1
match_parameter=>
'i'-case-insensitive
'c'-case-sensitive
'n'-allows the period (.), which is the match-any-character character, to match the newline character
'm'-treats the source string as multiple lines
'x'-ignores whitespace characters
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))') from dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
flying
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))',10) from
dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
flies
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))',10,2) from
dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))',10,2,'i')
from dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
Flies
====================
REGEXP_INSTR
====================
REGEXP_INSTR(source_char,pattern,position,occurrence,return_option,match_parameter)
source_char=>源字串
pattern=>正規表示式
position=>從source_char的第幾個字元開始搜尋,預設值1
occurrence=>返回第幾次匹配結果,預設值1
return_option=>
0-returns the position of the first character of the occurrence. Default
1-returns the position of the character following the occurrence
match_parameter=>
'i'-case-insensitive
'c'-case-sensitive
'n'-allows the period (.), which is the match-any-character character, to match the newline character
'm'-treats the source string as multiple lines
'x'-ignores whitespace characters
SQL> SELECT REGEXP_INSTR('500 Oracle Parkway, Redwood Shores, CA', '[s|r|p]', 3, 2, 1, 'i')
"REGEXP_INSTR" FROM DUAL;
REGEXP_INSTR
------------
13
SQL> SELECT REGEXP_INSTR('500 Oracle Parkway, Redwood Shores, CA', '[s|r|p]', 3, 2, 0, 'i')
"REGEXP_INSTR" FROM DUAL;
REGEXP_INSTR
------------
12
====================
REGEXP_REPLACE
====================
REGEXP_REPLACE(source_char,pattern,replace_string,position,occurrence,match_parameter)
SQL> SELECT REGEXP_REPLACE('500 Oracle Parkway, Redwood Shores, CA', '( ){2,}', ' ') "REGEXP_REPLACE" FROM DUAL;
REGEXP_REPLACE
--------------------------------------
500 Oracle Parkway, Redwood Shores, CA
REGEXP_SUBSTR
REGEXP_INSTR
REGEXP_REPLACE[@more@]====================
REGEXP_LIKE
====================
SQL> select * from t1;
COL1 COL2
---------- ----------
1 fly
2 flying
3 swim
4 Fly
5 Flies
SQL> select * from t1 where regexp_like(col2, 'fl(y(ing)?|(ies))');
COL1 COL2
---------- ----------
1 fly
2 flying
--'i' => 不區分大小寫
SQL> select * from t1 where regexp_like(col2, 'fl(y(ing)?|(ies))','i');
COL1 COL2
---------- ----------
1 fly
2 flying
4 Fly
5 Flies
====================
REGEXP_SUBSTR
====================
REGEXP_SUBSTR(source_char,pattern,position,occurrence,match_parameter)
source_char=>源字串
pattern=>正規表示式
position=>從source_char的第幾個字元開始搜尋,預設值1
occurrence=>返回第幾次匹配結果,預設值1
match_parameter=>
'i'-case-insensitive
'c'-case-sensitive
'n'-allows the period (.), which is the match-any-character character, to match the newline character
'm'-treats the source string as multiple lines
'x'-ignores whitespace characters
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))') from dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
flying
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))',10) from
dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
flies
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))',10,2) from
dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
SQL> select regexp_substr('Fly flying flies to Hangzhou flight Flies', 'fl(y(ing)?|(ies))',10,2,'i')
from dual;
REGEXP_SUBSTR('FLYFLYINGFLIEST
------------------------------
Flies
====================
REGEXP_INSTR
====================
REGEXP_INSTR(source_char,pattern,position,occurrence,return_option,match_parameter)
source_char=>源字串
pattern=>正規表示式
position=>從source_char的第幾個字元開始搜尋,預設值1
occurrence=>返回第幾次匹配結果,預設值1
return_option=>
0-returns the position of the first character of the occurrence. Default
1-returns the position of the character following the occurrence
match_parameter=>
'i'-case-insensitive
'c'-case-sensitive
'n'-allows the period (.), which is the match-any-character character, to match the newline character
'm'-treats the source string as multiple lines
'x'-ignores whitespace characters
SQL> SELECT REGEXP_INSTR('500 Oracle Parkway, Redwood Shores, CA', '[s|r|p]', 3, 2, 1, 'i')
"REGEXP_INSTR" FROM DUAL;
REGEXP_INSTR
------------
13
SQL> SELECT REGEXP_INSTR('500 Oracle Parkway, Redwood Shores, CA', '[s|r|p]', 3, 2, 0, 'i')
"REGEXP_INSTR" FROM DUAL;
REGEXP_INSTR
------------
12
====================
REGEXP_REPLACE
====================
REGEXP_REPLACE(source_char,pattern,replace_string,position,occurrence,match_parameter)
SQL> SELECT REGEXP_REPLACE('500 Oracle Parkway, Redwood Shores, CA', '( ){2,}', ' ') "REGEXP_REPLACE" FROM DUAL;
REGEXP_REPLACE
--------------------------------------
500 Oracle Parkway, Redwood Shores, CA
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/207/viewspace-1057245/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle regexp expressOracleExpress
- Oracle Regexp_ReplaceOracle
- oracle regexp_like用法與正則Oracle
- oracle regexp_like介紹和例子Oracle
- 【正則】oracle正規表示式函式之REGEXP_REPLACE和REGEXP_SUBSTROracle函式
- Oracle拆分逗號分隔字串 - REGEXP_SUBSTROracle字串
- Oracle中REGEXP_SUBSTR函式(字串轉多行)Oracle函式字串
- oracle正規表示式regexp_like的使用Oracle
- RegExp物件物件
- Oracle的regexp_like函式用法一例Oracle函式
- oracle 10g 正規表示式 REGEXP_LIKEOracle 10g
- JavaScript RegExp物件JavaScript物件
- RegExp.lastparenAST
- RegExp.lastMatchAST
- JavaScript RegExp 物件JavaScript物件
- oracle正規表示式regexp_like的用法詳解Oracle
- Oracle 正規表示式函式-REGEXP_REPLACE 使用例子Oracle函式
- oracle 10g正規表示式 REGEXP_LIKE 用法Oracle 10g
- 【轉】Oracle 正規表示式函式-REGEXP_REPLACE 使用例子Oracle函式
- 【轉】Oracle 正規表示式函式-REGEXP_LIKE 使用例子Oracle函式
- RegExp.leftContextContext
- 【轉】Oracle 正規表示式函式-REGEXP_INSTR 使用例子Oracle函式
- JS RegExp 替換字元JS字元
- oracle 按.反轉或按空格反轉之REGEXP_REPLACE應用Oracle
- RegExp.rightContextContext
- oracle lz047中的REGEXP_LIKE(cust_first_name,'[[:digit:]]')) 轉OracleGit
- JavaScript RegExp(正規表示式) 物件JavaScript物件
- go語言標準庫 - regexpGo
- 正規表示式RegExp.input
- Flutter Dart 正則RegExp [.....]和[^.....](一)FlutterDart
- Spark SQL,正則,regexp_replaceSparkSQL
- RegExp()建構函式的用法函式
- JavaScript中的Date,RegExp,Function物件JavaScriptFunction物件
- Javascript中使用RegExp的簡略指南JavaScript
- 【Mysql】instr與find_in_set與regexpMySql
- js學習四-RegExp正規表示式JS
- 詳解Go regexp包中 ReplaceAllString 的用法Go
- 匹配搜尋關鍵高亮 new RegEXP 填坑