How do I scan a string and bring different parts of it?

Asked

Viewed 105 times

0

Using REGEX it is possible to "concatenate" masks to bring different parts of the same string?

How do I scan a string and bring different parts of it?

  • I have a text field with the following information:

    00200.035219/2012-15 (VOLUME 1)

  • I want the return to be exactly like this:

    00200.035219/2012-15;1

The information you have after the semicolon always refers to the volume number.

I am using PL/SQL and REGEX.

  • 2

    Can return subgroups using regex: https://regex101.com/r/kemtne/1

  • @Panther Thank you very much! The regular expression I needed was just that. I only had one question: Which method should I use to write on the screen the subgroups $1;$2?

  • 2

    You can use the function REGEXP_REPLACE. Ex.: SELECT REGEXP_REPLACE(field, '([^ ]+) \(VOLUME ([^)]+)\)', '\1;\2') "replaced_field" FROM table.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.