0

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

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

Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
dreambigcoder
  • 1,859
  • 4
  • 22
  • 32

2 Answers2

1

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

Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
0

If you need with REGEXP_SUBSTR also, then:

SELECT REGEXP_SUBSTR ('https://test/test/test/test/getTest/1234' , '[^/]+$' )  from dual
Oto Shavadze
  • 40,603
  • 55
  • 152
  • 236