Reputation: 711
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
.
Upvotes: 0
Views: 1518
Reputation: 2596
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 ] ] ] ] )
Upvotes: 1