#NEWLINE# def _p_re( self , regexp , silent = False , swallow = True , group = 0 , syntax_error = None ) : #NEWLINE# #INDENT# "This will attempt to match (ie: at the beginning of the string)\n        the given regular expression with our current input string. If it\n        matches it will return what matched. If 'silent' is False, and it did\n        NOT match, then it will raise the NoMatch exception. If 'swallow' is\n        True, then it will chop off the matched characters from the beginning\n        of our input string.\n\n        If 'group' is specified (an integer!) it will be passed to the match\n        object's group() method letting the caller pick what part of the\n        match they wish returned to them. Of course the r.e. used must have\n        appropiate matching group's specified.\n\n        NOTE: If the match fails then we do NOT swallow any input even if\n              swallow = True\n        " #NEWLINE# match = regexp . match ( self . input ) #NEWLINE# if ( match is None ) : #NEWLINE# #INDENT# if silent : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if syntax_error : #NEWLINE# #INDENT# raise NoMatch ( value = syntax_error ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NoMatch ( value = ( "No match for r.e. '%s'" % regexp . pattern ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if swallow : #NEWLINE# #INDENT# self . input = self . input [ match . end ( ) : ] #NEWLINE# #UNINDENT# return match . group ( group )