Atomic grouping. (And, if your engine has it, possessive quantifiers, which are a notational convenience for the commonest use case of Atomic grouping)
This is very often the answer to making your regular expressions fast. Anyone who's struggled with regular expressions knows how easy it is to accidentally write a regular expression that takes forever on long input. As a simple example, this regex:
([+\w-]+)@foo.com
Takes time proportional to n2 to run against a string of n "x" characters. (with most engines; perl does some fancy optimization) It's easy to construct a regular expression that takes O(n3), O(n4), etc. time when failing to match, and even ones that take O(2n) time. Often, the way out of this is to signal to the regular expression engine that it shouldn't backtrack through certain constructs. That's where atomic grouping comes in.
This regular expression matches exactly the same things as the other one, but only takes O(n) time:
((?>[+\w-]+))@foo.com
The atomic group construct (?> ) tells the regular expression engine to not backtrack back inside the parentheses if subsequent characters fail to match. Instead, the entire expression should fail to match. This is what keeps the behavior linear.
You do have to be a little bit careful with atomic groups - sometimes you really do want backtracking - but it's a nice thing to start thinking of whenever you notice performance issues in your regular expressions.
(It's a shame Python doesn't support this feature - yet)