So what I have is a series of Strings all have a distinct 'MIN' in each string, for example:
abcdefMINjklkkase
ffffffffffMINxxxxxxxxxx
eeeMINoooooooooooooooooo
ggggggggMINkkkkkkk
wwwwwwwwwwwwwwwwMINiiiiiiii
All String sets are different length otherwise I would use LEFT function or LTRIM functions. The result I would like to get is,
abcdef
ffffffffff
eee
gggggggg
wwwwwwwwwwwwwwww
The variable, 'MIN' is consistent in all string sets just at various different lengths due to how the Strings are created.
Any help would be much appreciated!
-Maykid
#standardSQL
SELECT
str,
REGEXP_REPLACE(str, r'MIN.*', '') option_1,
REGEXP_EXTRACT(str, r'(.*?)MIN.*') option_2
FROM `project.dataset.table`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With