Skip to main content

I am trying to extract the date from a string. the date comes after '-'. The challenge is that there can be more than one instance of '- '.So, tried to find the '-'followed by a space and '/'after 3character

String sample: $$$$$ $$$$$$$: $$~$$$$ - $$$$ $$$$$$$$ $$$ $$$ ~$$$$ $$$$$$$$ $$/$$/$$$$ - 07/01/2022 $$$:$ $$$:$ $$$:$.$ ( i want to extract the date after the second '- ')

 

Code I used:(code gives me error)

CASE WHEN

MATCH_PROCESS_REGEX ( column, '.*- .{3,}/' )=1

THEN TO_DATE(RTRIM(RIGHT(STRING_SPLIT (column, '- ' , 0),11)),FORMAT ( '%d/%m/%Y'))

ELSE NULL

END

 

Thanks In Advance

Hmmm... if there is several instances of '-' but only one date, then maybe you should try to match '-" followed by a date...

 

testing in Regexpal, this pattern ' - (\\d\\d/\\d\\d/\\d\\d\\d\\d)' will match

 

image 

HTH


Reply