I want to write a regex in the variables page for a query. The regex should - exclude all values starting with "$.artemis" OR Values starting with "notif."
Try using (?!\$\.artemis|notif\.)(.+)
. We use a negative lookahead assertion with (?!...)
to make sure we do not match anything starting with notif.
or $.artemis
. Example:
>>> import re
>>> pattern = re.compile(r"(?!\$\.artemis|notif\.)(.+)")
>>> pattern.match("hello") # Match
<re.Match object; span=(0, 5), match='hello'>
>>> pattern.match("$hello") # Match
<re.Match object; span=(0, 6), match='$hello'>
>>> pattern.match("$.artemis") # No match
>>> pattern.match("$.artemiswithsomething") # No match
>>> pattern.match("notif.") # No match
>>> pattern.match("notif.a") # No match
>>> pattern.match("notifwithoutfullstop") # Match
<re.Match object; span=(0, 20), match='notifwithoutfullstop'>