Is it possible to extract pieces of text in a sentence containing X in a google sheet. In a Formula of via Apps script. I couldn't find a decent answer on google or didn't know what to search for.
For example:
A1: [Peter] kicks the [ball] to [Shaun].
I want to extract the first word containing '[' & ']' in B1, the second word containing '[' & ']' in C1, et cetera.
A | B | C | D | |
---|---|---|---|---|
[Peter] kicks the [ball] to [Shaun]. | [Peter] | [ball] | [Shaun] |
Try this
=regexextract(A1,regexreplace(regexreplace(A1,"[\[]","(\\\["),"[\]]","\\\])"))