Oracle REGEXP_SUBSTR removing substring

20 views Asked by At

From every String I want to remove the substring "withHugo"

I tried

SELECT REGEXP_SUBSTR('STRING-EXAMPLEwithHugo','(.+)withHugo') "REGEXPR_SUBSTR" FROM DUAL;

but it returns "STRING-EXAMPLEwithHugo" instead of "STRING-EXAMPLE". How can I REMOVE the 2nd part?

1

There are 1 answers

0
Gary_W On BEST ANSWER

You want REGEXP_REPLACE here to replace "withHugo" with an empty string:

SELECT REGEXP_REPLACE('STRING-EXAMPLEwithHugo','withHugo', '') "REGEXPR_SUBSTR" 
FROM DUAL;