Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Spreadsheets Regex Case Insensitive (Regexreplace)

Tags:

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!

like image 744
nate11000 Avatar asked Jul 09 '14 01:07

nate11000


People also ask

How do you make a regex case-insensitive in Google Sheets?

We can use the LOWER function as below for case-insensitive Regexmatch in Google Sheets. Use capital letters in the regular expression when using the UPPER function. If the regular_expression is cell reference, for example, B1, you should use lower(B1) or upper(B1) depending on A1 capitalization.

Are regex matches case-sensitive?

By default, the comparison of an input string with any literal characters in a regular expression pattern is case-sensitive, white space in a regular expression pattern is interpreted as literal white-space characters, and capturing groups in a regular expression are named implicitly as well as explicitly.


1 Answers

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]", "") 
like image 103
hwnd Avatar answered Sep 21 '22 11:09

hwnd