Lately I had to extract a variable series of numbers within a string. The string was like this ‘GG-78-45687’ or ‘FD-02-45679444-F4’.

In the first case I needed to get ‘45687’ and in the other case I needed to get ‘45679444’. Sometimes there are trailing caracters and the length of the series of numbers is 5.

This is the regexp function I’ve used :

select regexp_substr('FD-02-45679444-F4','[0-9]{5,}') from dual;

It worked for every situation on Oracle 11g.

Cheers !