O'Reilly logo
  • Oleg Demidenko thinks this is interesting:

         # LOOKAHEAD
         # Email addresses are wrapped in angle brackets, but only
         # if both are present or neither is.
         (?= (<.*>$) &...

From

Cover of The Python 3 Standard Library by Example, Second Edition

Note

lookahead checks remaining part of the string for some pattern in general, after lookahead is matched detailed matching of the same remaining string is done by the further part of regexp pattern. so, lookahead helps to have a more general match before detailed match. it helps to check for matching paired opening and closing symbols within a bigger expression. after lookahead -