Reputation: 364
I need to get all characters after the last 'R' from a part number like this:
223A GHH R337716
So far I've got:
REGEXP_SUBSTR(CUST_PART_NO,'R(.*)')
This returns R337716, but I don't want the 'R' and I'm not sure if it would work if there was more than one 'R' in the string.
Upvotes: 1
Views: 4746
Reputation: 23381
Then you have to replace the string with groups of expressions like this:
regexp_replace( CUST_PART_NO, '(.*)(R)(.*)', '\3' )
See it here on sqlfiddle: http://sqlfiddle.com/#!4/3ec77/2
What I'm saying with this expression is:
R
make it as a group 1 expression the first (.*)
R
make it the second group (R)
(.*)
The parenthesis on a regular expression define groups of expressions.
Upvotes: 8