Is it possible in SQL Server to extract a string with a REGEX?
Something like REGEXP_SUBSTR()
?
I know with patindex
I can use a REGEX to find the initial position, but I want it to extract directly the string that matches the pattern in the REGEX, does it exist in SQL Server?
Let's assume I have a message string like
@message =
'- Tomorrow: 75 degrees (bla xyz)
- Day 1: 78 degrees etc 3300 fx
- Day 2: 76 degrees ppp 99
- Day 3: 80 degrees xxx2 '
I need to extract in multiple string variables:
@tomorrow_temperature = '75'
@day_1_temperature '78'
@day_2_temperature '76'
@day_3_temperature '80'
How can I use REGEX to extract just the number associated to each day? Is there any function that given a REGEX extract automatically the matching string
I tried using PATINDEX
but that of course extracts just the starting position of the string, it doesn't tell me how long it is and I don't want to use fixed amount of characters, just extract the whole string and from that extract the number of degrees
SELECT Patindex('