Home > Mobile >  Regex Extract in Google Data Sttudio
Regex Extract in Google Data Sttudio

Time:04-17

How am I able to extract a string from an array within a field? I am able to use Breakdown Dimension to get the array, but I can't seem to figure out how to use REGEXP_EXTRACT to get just the 'friendly_name'.

I tried this REGEXP_EXTRACT(shared_attrs, '^friendly_name:\\s?"?([^";,]*)') but that didn't work.

enter image description here

CodePudding user response:

Use

REGEXP_EXTRACT(shared_attrs, 'friendly_name"?\\s*:\\s*"?([^"]*)')

See proof.

EXPLANATION

- "friendly_name" - matches the characters friendly_name literally (case sensitive)
- '"?' - matches the character " with index 3410 (2216 or 428) literally (case sensitive) between zero and one times, as many times as possible, giving back as needed (greedy)
 - "\s*" - matches any whitespace character (equivalent to [\r\n\t\f\v ]) between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 - ":" - matches the character : with index 5810 (3A16 or 728) literally 
 - "\s*" - matches any whitespace character (equivalent to [\r\n\t\f\v ]) between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 - '"?' -  matches the character " with index 3410 (2216 or 428) literally (case sensitive) between zero and one times, as many times as possible, giving back as needed (greedy)
1st Capturing Group ([^"]*)
 - Match a single character not present in the list below [^"]
 - "*" - matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 - '"' - matches the character " with index 3410 (2216 or 428) literally (case sensitive)
  • Related