Oracle Regular expression function-regexp_replace use example

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.