// Pattern
{{\s*.*?(?!contact\.firstName|contact\.lastName|contact\.phoneNumber|contact\.language)\s*}}
// String
test {{debug}} {{contact.language}} test {{another}}
I'm trying to match substrings that are between {{ }}
that are not in a certain set of strings (contact.firstName
, contact.lastName
, contact.phoneNumber
, contact.language
). Now in this example, it so happens that the text I wanted to exclude all have contact.
. But no, it could be any text, and may contain symbols and spaces.
In this example, I need to match {{debug}}
and {{another}}
. If I understand the regex correctly, it should match anything (even blank) other than those listed under (?! )
. However, it keeps matching {{contact.language}}
possibly due to the .*
part.
How does one match anything other than those defined in the set? I'm not particularly adept in regex, as I don't really use it on an everyday basis.