Drive2blue
Drive2blue

Reputation: 127

Extract characters between a string and the first occurrence of something in BigQuery

I want to extract a set of characters between "u1=" and the first semi-colon using a regex. For instance, given the following string: id=1w54;name=nick;u1=blue;u2=male;u3=ohio;u5=

The desired regex output should be just blue.

I tested (?<=u1=)[^;]* on https://regex101.com and it works. However, when I run this in BigQuery, using regexp_extract(string, '(?<=u1=)[^;]*') , I get an error that reads "Cannot parse regular expression: invalid perl operator: (?<"

I'm confused why this isn't working in BQ. Any help would be appreciated.

Upvotes: 0

Views: 1772

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269553

You can use regexp_extract() like this:

regexp_extract(string, 'u1=([^;]+)')

Upvotes: 2

Related Questions