def __init__( self, pattern, flags=<NUM_LIT:0>):
super(Regex,self).__init__()<EOL>if isinstance(pattern, basestring):<EOL><INDENT>if len(pattern) == <NUM_LIT:0>:<EOL><INDENT>warnings.warn("<STR_LIT>",<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT>self.pattern = pattern<EOL>self.flags = flags<EOL>try:<EOL><INDENT>self.re = re.compile(self.pattern, self.flags)<EOL>self.reString = self.pattern<EOL><DEDENT>except sre_constants.error:<EOL><INDENT>warnings.warn("<STR_LIT>" % pattern,<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>raise<EOL><DEDENT><DEDENT>elif isinstance(pattern, Regex.compiledREtype):<EOL><INDENT>self.re = pattern<EOL>self.pattern =self.reString = str(pattern)<EOL>self.flags = flags<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.name = _ustr(self)<EOL>self.errmsg = "<STR_LIT>" + self.name<EOL>self.mayIndexError = False<EOL>self.mayReturnEmpty = True<EOL>
The parameters C{pattern} and C{flags} are passed to the C{re.compile()} function as-is. See the Python C{re} module for an explanation of the acceptable patterns and flags.