I have a string in the format 12345Q999W12345. Basically, some digits followed by 'Q' followed by more digits, followed by 'W' and ends in more digits. I want to extract the number between the characters 'Q' and 'W'. The best that I have been able to come up with is:
select regexp_substr( '12345Q999W12345' , 'Q[^(\d+)$]+W' ) from dual;
The output that I get from the above is:
Q999W
Any pointers on how to further refine this regexp?