0

I have a table column full of strings like this:

'top-level:volume(1):semifinished(21491628):serial(21441769)'.

I would like to return just the numbers after 'serial' (i.e. '21441769') using regex_substr().

select ('top-level:volume(1):semifinished(21491628):serial(21441769)', ????)

Drake
  • 25
  • 1
  • 4

2 Answers2

1

Try this "(?<=serial().[0-9]+"

jak dev
  • 33
  • 1
  • 8
  • Thank you. I tried it and received this warning: "Invalid regular expression: '(?<=serial().[0-9]+', no argument for repetition operator: ?" – Drake Sep 21 '22 at 23:51
  • Weird I pasted it with this but it looks like it did not show up... You need to escape the ( with a backslash \ – jak dev Sep 22 '22 at 00:00
1

We can use REGEXP_SUBSTR with a capture group:

SELECT col, REGEXP_SUBSTR(col, 'serial\\((\\d+)\\)', 1, 1, 'e', 1) AS serial
FROM yourTable;
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360