7

According to Google Query documentation:

matches - A (preg) regular expression match. haystack matches needle is true if the regular expression in needle matches haystack. Examples: where country matches '.*ia' matches India and Nigeria, but not Indiana. Note that this is not a global search, so where country matches 'an' will not match 'Canada'.

I tried to use it in the formula =query('Общий список'!A3:V;"select * where B matches '/[A-Z]+/' "), but the query returns empty output.

Reference: https://developers.google.com/chart/interactive/docs/querylanguage#Where

4
  • Have you tried it without the forward slashes? Commented Dec 12, 2013 at 21:17
  • yep, same result.
    – Gleb
    Commented Dec 12, 2013 at 23:03
  • 1
    Why don't you share a doc with us?
    – Jacob Jan
    Commented Dec 15, 2013 at 21:03
  • I just realised that the sheet title is cyrillic. You may need to add an extra range for the upper case Russian(?) characters. Commented Dec 30, 2013 at 23:40

2 Answers 2

11

Note that this is not a global search...

This sentence explains what is going on: unlike the match in regexmatch, the matches clause of Query language requires the entire string to match the given regular expression. So, if you want to match strings where some part matches a regular expression re, the regular expression should be wrapped in .*:

select * where A matches '.*re.*'
5

Just a guess, but OP may want something like this:

=query(A:A, "Select A where A matches '.*/[A-Z]+/.*' ")  

to select from ColumnA only cells containing nothing but Latin alphabet upper case letters between two virgulas suspensiva (forward slashes) whether or not in the context of other characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.