Zahra Safdari
Zahra Safdari

Reputation: 25

How to make one capturing group of regular expression on bigquery?

I am getting the following error: Regular expressions passed into extraction functions must not have more than 1 capturing group.

And this is what I am trying to extract : regexp_substr(UPPER(tags), r'(TG\d{6})|(BD\d{6})')
Does anyone know how can I change this to one capturing group?
Any help would be appreciated.

Upvotes: 1

Views: 1856

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

Use either of below instead

regexp_substr(UPPER(tags), r'(TG\d{6}|BD\d{6})')         

or

regexp_substr(UPPER(tags), r'(?:TG|BD)\d{6}')

Upvotes: 1

Related Questions