Q:

Using re for equality

Is it possible to use regular expressions for equality.
How can I make this code:
import re
re.match(pattern, string)

Return True the same was as this code would:
pattern == string

A:

If the pattern begins with ^, ends with $, and contains no special RE operators (or they're escaped), it will perform an equality test.  E.g. 
re.match(r'^abc$', string)
re.match(r'^foo\|bar$', string)

can be used like
string == 'abc'
string == 'foo|bar'

