0

I need to extract the number/numbers that come after the last letter in a given string, using regexp or any other possible function.

For example, if the string is 'a23kfj879lp999', I need only 999 since the last letter in the string is p.

1 Answer 1

1

Use the REGEX_SUBSTR function:

SELECT REGEXP_SUBSTR('a23kfj879lp999', '([0-9]+)$') FROM dual

Explanation:

REGEX_SUBSTR simply extracts the first substring from the source string that matches the respective pattern.

Syntax:

REGEXP_SUBSTR( string, pattern [, start_position [, nth_appearance [, match_parameter [, sub_expression ] ] ] ] )
Sign up to request clarification or add additional context in comments.

2 Comments

An explanation would be appreciate
@Frank [0-9] at first means the output should start with a numerical and + says numerical can occur 1 or more times. $ at the end indicates the string ends there ie. no more characters are present after the occurence of numericals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.