Google Spreadsheets Regex Case Insensitive(Regexreplace)

nat*_*000 20 regex google-apps google-sheets

我正在尝试使用regexreplace函数在Google Spreadsheets中创建一个不区分大小写的正则表达式查询.那可能吗?我已经尝试了\ i标志并得到#REF错误说表达式无效:= regexreplace("Test","t\i","")给出错误,当我希望得到"es"作为最后结果.

可能吗?Google Spreadsheets中是否存在区分大小写的标志?

提前致谢!

hwn*_*wnd 30

AFAIK,启用不区分大小写的匹配的唯一方法是google docs中的JavaScript API.

显然,RE2语法确实支持内联(?i)不区分大小写的修饰符:

=REGEXREPLACE("Test", "(?i)t", "")
Run Code Online (Sandbox Code Playgroud)

另一个可行的方法是使用Character类,添加两个字母的大小写T.

=REGEXREPLACE("Test", "[Tt]", "")
Run Code Online (Sandbox Code Playgroud)

  • Google表格允许使用特定的正则表达式标志,包括用于不区分大小写的`i`.见[Alexander Ivanov的回答](http://stackoverflow.com/a/29094096/445295). (2认同)

con*_*rpw 13

我找到了这个:

=REGEXREPLACE("Test","(?i)t","")
Run Code Online (Sandbox Code Playgroud)

它返回你想要的东西

es
Run Code Online (Sandbox Code Playgroud)

谷歌/ RE2

  • 它起作用是因为您正在向正则表达式添加一个标志。“i”标志代表不区分大小写的匹配,因此它将匹配任何小写或大写的 T。参见 https://github.com/google/re2/blob/master/doc/syntax.txt (2认同)