Home > Software engineering >  Find n characters after a specific string in BigQuery
Find n characters after a specific string in BigQuery

Time:03-28

I want to get the first 4 characters after the word "hello_" in sql

here are example strings:

"hello_abcd_gjfnjg" , "hello_ab12_tg23" 

desired output:

"abcd", "ab12"

Here is my regex expression:

(hello_)(....)

But I get an error because its in groups:

Regular expressions passed into extraction functions must not have more than 1 capturing group

Is there a simpler regex expression without grouping?

CodePudding user response:

You can use just one capturing group like this: hello_(.{4})

Test regex here: https://regex101.com/r/QZPc3r/1

  • Related