Comment Comment by asah speaking as an old regexp wizard from before perl5, this is indeed a great trick, have an upvote.sadly, this trick still requires a code comment to explain. Python example: # match tarzan but not "tarzan" # see https://news.ycombinator.com/item?id=27774584 if "tarzan" == re.search(r'"tarzan"|(tarzan)', myvar)[1]: ... which in practice means it probably deserves a function: if re_search_but_exclude(r'tarzan', myvar, '"tarzan"'): ... I don't recommend monkeypatching re, i.e. re.search_but_exclude = ... parent asah 5 years ago
sadly, this trick still requires a code comment to explain. Python example:
which in practice means it probably deserves a function: I don't recommend monkeypatching re, i.e. re.search_but_exclude = ...