Search code examples
regexoracle-databaseslug

Making unique slug url in Oracle


I am trying to make unique slug URL in oracle using with regular expression. How can I get numeric value end of URL like that lorem-ipsum-dolor-2. My purpose that; Before I check inserted title if exist on table, check it numeric value end of URL if exist slug URL, if has numeric value increase it and save. I have tried the following regular expression that worked properly in C# but it not work in Oracle.

select regexp_like('lorem-ipsum-dolor-2','(\d+)*$') from dual;

Solution

  • What you are doing is almost correct.

    But instead of regexp_like' you need to useregexp_substr`:sp

    select regexp_substr('lorem-ipsum-dolor-2','\d+$') from dual;