Google sheet QUERY + MATCHES function doesn't exclude strings

我只是一个虾纸丫 提交于 2021-02-05 07:44:41

问题


I would like to import rows from a sheet that exclude certains character. I did it first using the CONTAINS function but i didn't find a way to do it with multiple parameters. So i did it using the MATCHES function :

=Query(importrange("URL";"Sheet!a:be");"SELECT Col1, Col3, Col4, Col26, Col8, Col30, Col40, Col41, Col44, Col45, Col49 WHERE NOT Col8 MATCHES '.*alc.*|.*vin.*|.*alcool.*'")

however there is still rows where those strings appear in Col8, i don't know why ?

How could i do it in order to filter my import excluding those strings no matter what ?


回答1:


In case the rows are not filtered out because of MATCHES is case sensitive (it is, and one cannot use flags in QUERY's regex), you can use FILTER instead:

=FILTER(
  QUERY(
    IMPORTRANGE("URL"; "Sheet!A:BE");
    "SELECT Col1, Col3, Col4, Col26, Col8, Col30, Col40, Col41, Col44, Col45, Col49"
  );
  NOT(REGEXMATCH(IMPORTRANGE("URL"; "Sheet!H:H"); "(?i)alc|vin|alcool"))
)


来源:https://stackoverflow.com/questions/65169244/google-sheet-query-matches-function-doesnt-exclude-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!