Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using RegExp to remove unnecessary texts in a column.

1004278Sep 16 2013 — edited Sep 17 2013

Hello Everyone,

I have a string that contains a lot of data separated by a semicolon. Now, what I want to do is to extract all of my needed data which are just hardware. Here is an example of the text:

DUTBOARD|A1DT25522;LOADBOARD|A2LB1896;PROBECARD|A4PC40257;PROGRAMNAME|DS2781;TESTOPTION|POSTBAKE;TESTTEMP|ROOM TEMP

Now what I want is for it to be just like this:

DUTBOARD|A1DT25522;LOADBOARD|A2LB1896;PROBECARD|A4PC40257;


What I was planning to do is to just get the DUTBOARD, LOADBOARD and PROBECARD and just concatenate it. Below sql code gets the value of the Loadboard:

SELECT

  regexp_substr('LOADBOARD|A2LB12833;PROGRAMNAME|MAX2659_H;PROGRAMREV|H;TESTOPTION|FR2659_H;TESTTEMP|25;STD IPH|6545.4545454545', '(;|^)LOADBOARD\|(.*)(;|$)', 1, 1, '', 2) lol

FROM dual;

My problem is that it returns all of the text past the LOADBOARD instead halting when it sees a semicolon. Can you help me? By the way I am using oracle 11g

Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 15 2013
Added on Sep 16 2013
5 comments
229 views