dreambigcoder
dreambigcoder

Reputation: 1907

ORACLE:SQL REGEXP_SUBSTR that returns the column value after last backslash(/)

ORACLE:SQL REGEXP_SUBSTR that returns the column value after last backslash(/)

example: https://test/test/test/test/getTest/1234 expected value: 1234

Upvotes: 0

Views: 612

Answers (2)

Gurwinder Singh
Gurwinder Singh

Reputation: 39507

You don't need regular expressions for this. You can simply using substr and instr which are likely to perform faster:

select
  substr(col, instr(col, '/', -1) + 1)
from t;

Demo

If you must use regexp_substr (for some reason) then use:

select regexp_substr(col, '[^/]+$') from t;

Demo

Upvotes: 1

Oto Shavadze
Oto Shavadze

Reputation: 42783

If you need with REGEXP_SUBSTR also, then:

SELECT REGEXP_SUBSTR ('https://test/test/test/test/getTest/1234' , '[^/]+$' )  from dual

Upvotes: 0

Related Questions