The original is here: Poke
6 parameters
The first one is the string entered
The second one is the regular expression
The third one is the substituted character
The fourth is to identify a regular expression match starting from the first few characters. (Default is 1)
The fifth one is to identify the first few matching groups. (default to replace All)
The sixth one is the value range:
I: case is not sensitive;
C: Case sensitive;
N: Point number. Do not match line break symbols;
M: multi-line mode;
X: Extended mode, ignoring white-space characters in regular expressions.
All test data
Sql> select * from Test_reg_substr;
A
-----------------------------------
Abc123xyz
abc123xyz456
Edward
Replace number
Sql> SELECT
2 Regexp_replace (A, ' [0-9]+ ', ' QQQ ') as a
3 from
4 test_reg_substr;
A
-----------------------------------------------
Abcqqqxyz
Abcqqqxyzqqq
Edward
Replace the number (starting with the first letter, replacing the 1th matching items)
Sql> SELECT
2 Regexp_replace (A, ' [0-9]+ ', ' QQQ ', 1, 1) as a
3 from
4 test_reg_substr;
A
------------------------------------------------------
Abcqqqxyz
ABCQQQXYZ456
Edward
Replace the number (starting with the first letter, replacing the 2nd matching items)
Sql> SELECT
2 Regexp_replace (A, ' [0-9]+ ', ' Q ', 1, 2) as a
3 from
4 test_reg_substr;
A
---------------------------------------------------
Abc123xyz
Abc123xyzq
Edward
Replace a second word
Sql> SELECT
2 Regexp_replace (A, ' \w+ ', ' Kimi ', 1, 2) as a
3 from
4 test_reg_substr;
A
---------------------------------------------------
Abc123xyz
abc123xyz456
Kimi
Oracle Regular expression function-regexp_replace use example