Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regexp_Extract – Data Studio extract value after second underscore

I have a simple string separated by underscores from which I need to pull all the values after a specific underscore using a regular expression with the REGEXP_EXTRACT formula in Google Data Studio

The strings look like this:

ABC123_DEF456_GHI789-JKL274

Basically the values after the second underscore can be alphanumeric or symbols as well.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I need to pull the values after the second underscore. In the case of the example I gave, it would be:

GHI789-JKL274

Any ideas would be greatly appreciated.

Of course, many thanks in advance.

>Solution :

You need to use

REGEXP_EXTRACT(some_field, "^(?:[^_]*_){2}([^_]*)")

See the regex demo.

Details:

  • ^ – start of string
  • (?:[^_]*_){2} – two occurrences of any zero or more chars other than _ and then a _
  • ([^_]*) – Capturing group #1: zero or more chars other than _.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading