1

I'm trying to match strings using a Google Sheets query where both strings are uncertain if they contain special characters. I'll try to explain as best as I can:

I have a table of data

+-----+------+-----+-----+
|  A  |   B  |  C  |  D  |
|x    | y    |ø    |z    |
|xx   | yy   |á    |zz   |
|xxx  | yyy  |e    |zzz  |
+-----+------+-----+-----+

My query function would look something like this:

=QUERY(A1:D3, "SELECT * WHERE (C = 'ø') OR (C = 'è') OR (C = 'a')")

Currently, using this query will only return 1 row because, (C = 'ø') is an exact match with 'ø', however none of the others have a match.

For (C = 'è'), we can just replace all of the accented characters in the string with their un-accented equivalent.
In this case 'è' becomes 'e' and has a match - now the query will return a second row.

(I found a nice way to replace all accented characters in a string here.)

Finally, here is where my main problem sits: (C = 'a'). I can't figure out a way to make it match 'á', unless I check every accented variant of 'a', but that just seems silly.
It's not possible to do something like "... WHERE (CUSTOM_FUNCTION(C) = 'a')" either, sadly.

As I previously mentioned, either side of the match may or may not contain accented/special characters.
I should also mention that it wont be just a single character, it will be a whole string.

If anyone has any possible solutions to this, it would be greatly appreciated.

marikamitsos
  • 10,264
  • 20
  • 26
user3208218
  • 65
  • 1
  • 8

1 Answers1

2

Instead of the QUERY formula, you could use a FILTER formula.

=FILTER(A2:D22,REGEXMATCH(C2:C22,"ø|è|á")=TRUE)

(Please adjust ranges to your needs. You can also add/remove more special characters.)

enter image description here

Functions used:

marikamitsos
  • 10,264
  • 20
  • 26