Google 工作表中的正则表达式
Regular Expressions in Google Sheets
我正在尝试在 Google 表格中使用正则表达式。鉴于环境在 GSheets 中,某些功能似乎缺失或可能只是不同。
我想使用正则表达式匹配函数,如果相关范围包含以下任何字符串,returns 为真:
"string1"
"string2"
"string3"
我试过了=regexmatch(range,"([Ss]tring1|[[Ss]tring2|[Ss]tring3)"
这有效。
但是我的开发同事说他通常只是结束表达式 /i
说 "Be case insensitive"
=regexmatch(range,"/(String1|String2|String3)/i"
但由于 Gsheets 不使用“/”打开正则表达式,是否有其他方法告诉函数忽略大小写?
另外,有没有办法否定表达式?也就是说,而不是:
=NOT(regexmatch(range,"([Ss]tring1|[[Ss]tring2|[Ss]tring3)")
你能做类似的事情吗
=regexmatch(range,"!=([Ss]tring1|[[Ss]tring2|[Ss]tring3)"
is there another way to tell the function to ignore case?
请尝试:
=regexmatch(range,"(?i)string1|string2|string3")
您可以尝试使用 "lower" 函数包裹您的范围,这样比较值时就好像它们都是小写的,不管它们是否真的是小写。
=REGEXMATCH(lower(range),"string1|string2|string3")
我正在尝试在 Google 表格中使用正则表达式。鉴于环境在 GSheets 中,某些功能似乎缺失或可能只是不同。
我想使用正则表达式匹配函数,如果相关范围包含以下任何字符串,returns 为真:
"string1" "string2" "string3"
我试过了=regexmatch(range,"([Ss]tring1|[[Ss]tring2|[Ss]tring3)"
这有效。
但是我的开发同事说他通常只是结束表达式 /i
说 "Be case insensitive"
=regexmatch(range,"/(String1|String2|String3)/i"
但由于 Gsheets 不使用“/”打开正则表达式,是否有其他方法告诉函数忽略大小写?
另外,有没有办法否定表达式?也就是说,而不是:
=NOT(regexmatch(range,"([Ss]tring1|[[Ss]tring2|[Ss]tring3)")
你能做类似的事情吗
=regexmatch(range,"!=([Ss]tring1|[[Ss]tring2|[Ss]tring3)"
is there another way to tell the function to ignore case?
请尝试:
=regexmatch(range,"(?i)string1|string2|string3")
您可以尝试使用 "lower" 函数包裹您的范围,这样比较值时就好像它们都是小写的,不管它们是否真的是小写。
=REGEXMATCH(lower(range),"string1|string2|string3")