2

You can use the pipe | to represent OR and it works fine in Google Sheets. But I want an AND operator and can't find that anywhere. The closest post I found was talking about java application but it doesn't run properly on Google Sheets

I want to check if in the string "equivalencia de estudo patrimonial" the strings "equivalencia" and "patrimonial" are present.

I've already tried:

=regexmatch("equivalencia de estudo patrimonial";"(?:equivalencia)(?:patrimonial)")
=regexmatch("equivalencia de estudo patrimonial";"(?=equivalencia)(?=patrimonial)")
=regexmatch("equivalencia de estudo patrimonial";"/(equivalencia)(patrimonial)/")
=regexmatch("equivalencia de estudo patrimonial";"(equivalencia)(patrimonial)")

No one worked. Always getting false.

Can someone help here?

aabujamra
  • 4,494
  • 13
  • 51
  • 101

1 Answers1

2

Unfortunately, RE2 library that powers Google Sheets does not support lookarounds.

What you may do is match a combination of word1.*word2 or word2.*word1 with a regex like

=REGEXMATCH("equivalencia de estudo patrimonial"; "equivalencia.*patrimonial|patrimonial.*equivalencia")

Here, equivalencia.*patrimonial|patrimonial.*equivalencia matches equivalencia, some 0+ chars, patrimonial, or (|) patrimonial.*equivalencia matches patrimonial, then any 0+ chars and then equivalencia. It is not that efficient due to the .* part between the two words.

Another solution is to use the AND function and run REGEXMATCH twice:

=AND(REGEXMATCH(A1;"equivalencia"); REGEXMATCH(A1; "patrimonial"))
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563