Search code examples
regexgoogle-sheetsgoogle-sheets-formulaescapingre2

How to ignore parenthesis in a REGEXMATCH?


I am attempting to sum up values based on matching a substring. The issue I am running into is that the substring and string both have parenthesis and therefore the match is failing.

I have created a sample sheet to show the basics of what is going on.

A little more context, the idea is to sum up all the projects that have the same start but can have different - allocations. Any help making E2 correctly find the 3 Innovation Lap (TEST) Projects but not the 1 Test Innovation Lab (TEST) Projects.

I tried a SUMIF but it did not allow the level of detail I wanted.


Solution

  • you need to escape them with backslash \

    =REGEXMATCH(B21; "te\(\)st")
    

    enter image description here

    injected into the 2nd argument, it would be:

    =REGEXMATCH(B21; REGEXREPLACE(C21; "(\(.+)(\))"; "\\$1\\$2"))
    

    enter image description here