sqlregexexasol

Extract UoM text between two round brackets only after a specific string


I have a large string in the form of

Anschlüsse/Schnittstellen=(USB 3.0)|Bildschirmgröße=59,9 cm (23,6 Zoll)|Bluetooth=Bluetooth 4.0|

I need to extract 23,6 out of Bildschirmgröße=59,9 cm (23,6 Zoll)|

I tried

/(?<=Bildschirmgröße=)(?:.+?\()(.*?)(?:\))(?=\|)

but that returns 2 matches

59,9 cm (23,6 Zoll)
23,6 Zoll

and in my SQL query I only get the first result instead of the second.

Trying to only get the correct match via

(?<=Bildschirmgröße=)(?:.+?\()(\(.*?\))(?:\))(?=\|)

returns nothing/NULL?


Solution

  • What you get is not actually two matches, you get the whole match value and the Group 1 value.

    In order to get just the UoM value, you can use the following PCRE compliant pattern (since Exasol uses PCRE behind its regex functions):

    Bildschirmgröße=[^(]*\(\K[^()]+
    

    See the regex demo.

    To only get the number, you can use

    Bildschirmgröße=[^(]*\(\K\d+(?:,\d+)?
    

    See this regex demo.

    Details: