def escape_regex(p, white=u''):
 return u''.join(((c if (c.isalnum() or (c in white)) else (u'\\000' if (c == u'\x00') else (u'\\' + c))) for c in p))

def escape_regex ( p , white = u'' ) : return u'' . join ( ( ( c if ( c . isalnum ( ) or ( c in white ) ) else ( u'\\000' if ( c == u'\x00' ) else ( u'\\' + c ) ) ) for c in p ) )
escape string for use within a regular expression .