I want use the function REGEXEXTRACT in a Google spreadsheets for retrive a string between brackets.
ex.
in the cell A1 I have the text: qwertyui (asdfghjk)
I need the text asdfghjk.
The function =REGEXEXTRACT(A1, "\(([A-Za-z /]+)\)") works finely but when I have a text like qwertyui ([asdfghjk]) the function doesn't return nothing because the regular expression that I use does not have the square brackets.
I tried to add the characters "[" and "]" but they are metacharacters. I used the notation \[ (and \]) but don't works.
Google spreadsheets use regular expression re2. Is the notation correct?
Anyone know how to escape from metacharacters (or where I am wrong)?
Use "\(([A-Za-z\[\] /]+)\)" or ("smart" placement) "\(([][A-Za-z /]+)\)".

or

However, since you are just extracting any text inside parentheses, you can make use of a negated character class [^()] that matches any character but a ( and ).
=REGEXEXTRACT(A1, "\(([^()]+)\)")

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With