Google Spreadsheets Regex Case Insensitive (Regexreplace)

nate11000 picture nate11000 · Jul 9, 2014 · Viewed 17.5k times · Source

I'm trying to create a case insensitive regex query in Google Spreadsheets with the regexreplace function. Is that possible? I've tried the \i flag and got a #REF error saying the expression was invalid: =regexreplace("Test","t\i","") gives an error when I would hope to get "es" as the final result.

Is it possible? Is there a flag for case sensitivity in Google Spreadsheets?

Thanks in advance!

Answer

hwnd picture hwnd · Jul 9, 2014

AFAIK, the only way to enable case-insensitive matching is JavaScript API in google docs.

Apparently, RE2 syntax does support the inline (?i) case-insensitive modifier:

=REGEXREPLACE("Test", "(?i)t", "")

An alternative that will work is using a Character class, adding both cases of the letter T..

=REGEXREPLACE("Test", "[Tt]", "")