The Oracle regular expression REGEXP_REPLACE uses

Example: How does oracle write sql to extract specific content? The example is as follows, the content in the left picture is a string of text, and the "test, other, existence" is extracted from the text to a separate column on the right.

 

You can use regular expressions to replace multiple x, the specific statement is as follows:

SELECT REGEXP_REPLACE('xxxx测试xx其他xxxx等等xxx存在', 'x{2,}', ',') as replaced_string FROM dual;

The execution result is:

replaced_string
-----------------
,测试,其他,存在

Among them, the regular expression x{2,}means to match two or more consecutive x. The second parameter is the substring to be replaced, and the third parameter is the string to be replaced. Therefore, after the above SQL statement is executed, consecutive occurrences of x are replaced with a comma.

Guess you like

Origin blog.csdn.net/Allenzyg/article/details/130428185