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

REGEXEXTRACT to capture group of strings between 2 characters

I have the following working gsheet formula that transposes, split, trims using REGEXEXTRACT which works to capture the first group of strings separated by OR

=transpose(split(IFERROR(TRIM(REGEXEXTRACT(A2,"([^\()]+)")))," OR ",FALSE))

Example below using formula above

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

("AD" OR "AB" OR "ZZ" OR "Short Long" OR "Long Short") w/5 (("foo bar*" OR "bar* foo" OR "kit kat*") w/5 ("ping* pong game*" OR "ppg") w/5 ("bro" OR "sis" OR "fam"))

extracts the following for group 1

  • "AD"
  • "AB"
  • "ZZ"
  • "Short Long"
  • "Long Short"

How to extract other groups that are in between w/5 string? Note that there can be multiple instances of w/5 from a given statement. Example above have 3.

Expected output group 2

  • "foo bar*"
  • "bar* foo"
  • "kit kat*"

Expected output group 3

  • "ping* pong game*"
  • "ppg"

Expected output group 4

  • "bro"
  • "sis"
  • "fam"

>Solution :

Let me know if this works for you!

=TRANSPOSE(INDEX(SPLIT(INDEX(REGEXEXTRACT(TRANSPOSE(split(A2," w/5 ",FALSE)),"([^\()]+)"))," OR ",false)))

enter image description here

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