Search code examples
regexoracle-databasesubstr

REGEXP_SUBSTR-Oracle


How do I get the all words after the 4th forward slash from below using REGEXP_SUBSTR?(using oracle sql)

/plt/v1/v2/shipment-mgr/grids/shipoppre

all I need is

shipment-mgr/grids/shipoppre

Thanks


Solution

  • Assuming the column name is col1:

    select substr(col1, instr(col1, '/', 1, 4) + 1)
    from ...
    

    You DON'T need regexp; whenever you can use standard substr and instr, it's better, since regexp is slower.