ORACLE中的支持正則表達式的函數主要有下面四個:
1,REGEXP_LIKE :與LIKE的功能相似
2,REGEXP_INSTR :與INSTR的功能相似
3,REGEXP_SUBSTR :與SUBSTR的功能相似
4,REGEXP_REPLACE :與REPLACE的功能相似
它們在用法上與Oracle SQL 函數LIKE、INSTR、SUBSTR 和REPLACE 用法相同。
格式:
REGEXP_INSTR (source_string, pattern
[ , position
[, occurrence
[, return_option
[, match_parameter ]
]
]
]
)
[ , position
[, occurrence
[, return_option
[, match_parameter ]
]
]
]
)
參數說明:
source_string:輸入的字符串
pattern:正則表達式
position:標識從第幾個字符開始正則表達式匹配。(默認為1)
occurrence:標識第幾個匹配組。(默認為1)
return_option:0——返回第一個字符出現的位置。1:pattern下一個字符起始位置。
match_parameter:取值范圍
i:大小寫不敏感;
c:大小寫敏感;
n:點號 . 不匹配換行符號;
m:多行模式;
x:擴展模式,忽略正則表達式中的空白字符。
例:
select REGEXP_SUBSTR(
'
111,aaaa,222
',
'
[^,]+
',
1,
2)
from dual
結果:aaaa
