Class e.c.p.PatternMatcher(Loggable):

Part of elisa.core.pattern_matcher View In Hierarchy

Known subclasses: elisa.core.pattern_matcher.UriPatternMatcher

Object used to map strings matching regex patterns to python objects.
Line # Kind Name Docs
80 Method __init__ Undocumented
83 Method add_pattern Assign an object to a regex pattern.
96 Method remove_pattern Remove a regex pattern.
114 Method match Match string to the list of patterns in the resolver and return the
def __init__(self):
Undocumented
def add_pattern(self, regex, obj):
Assign an object to a regex pattern.
Parametersregexregular expression (type: str )
objthe object to assign to strings matching regex (type: any python object )
def remove_pattern(self, regex):
Remove a regex pattern.
Parametersregexregular expression (type: str )
RaisesPatternNotFoundwhen the pattern is not found
def match(self, string, all=False):
Match string to the list of patterns in the resolver and return the associated object.

This tries to match the pattern against the whole string, and not only the beginning of the string as re.match() does. Append '.*' to your regular expression if you want the same behaviour as re.

Parametersstringstring to match (type: str )
allwhether to return all the matches or only the first one (type: bool )
RaisesMatchNotFoundthere was no match for the given string
API Documentation for Elisa Media Center, generated by pydoctor at 2009-02-16 19:15:05.