Looking for a bit of regex help. I\'d like to design an expression that matches a string with \"foo\" OR \"bar\", but not both \"foo\" AND \"b
I don't think this can be done with a single regular expression. And boundaries may or may not work depending on what you're matching against.
I would match against each regex separately, and do an XOR on the results.
foo = re.search("foo", str) != None
bar = re.search("bar", str) != None
if foo ^ bar:
# do someting...