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_replace to remove part of a string

abe50Sep 10 2016 — edited Sep 11 2016

Hi,

I am trying to remove a chunk of a string after a third pattern match:

Here is an example:

Original string: /x-x-x-x/home1/home/M

trying to achieve: /x-x-x-x/home1

Basically I am trying to remove everything after the third occurrence of '/'...

Here is part of my first attempt..

when regexp_replace (filepath. '/',1) > 2

thenĀ  regexp_replace(filepath, '/', '',1,3)

This just replaces one character... Is there away to wildcard and remove using regexp_replace?

Thanks for the help in advance.

-Abe

This post has been answered by Frank Kulash on Sep 10 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2016
Added on Sep 10 2016
4 comments
3,343 views