|
def | __init__ (self, match_string, maxMismatches=1) |
|
def | parseImpl (self, instring, loc, doActions=True) |
|
def | __init__ (self) |
|
def | __init__ (self, savelist=False) |
|
def | copy (self) |
|
def | setName (self, name) |
|
def | setResultsName (self, name, listAllMatches=False) |
|
def | setBreak (self, breakFlag=True) |
|
def | setParseAction (self, *fns, **kwargs) |
|
def | addParseAction (self, *fns, **kwargs) |
|
def | addCondition (self, *fns, **kwargs) |
|
def | setFailAction (self, fn) |
|
def | preParse (self, instring, loc) |
|
def | postParse (self, instring, loc, tokenlist) |
|
def | tryParse (self, instring, loc) |
|
def | canParseNext (self, instring, loc) |
|
def | parseString (self, instring, parseAll=False) |
|
def | scanString (self, instring, maxMatches=_MAX_INT, overlap=False) |
|
def | transformString (self, instring) |
|
def | searchString (self, instring, maxMatches=_MAX_INT) |
|
def | split (self, instring, maxsplit=_MAX_INT, includeSeparators=False) |
|
def | __add__ (self, other) |
|
def | __radd__ (self, other) |
|
def | __sub__ (self, other) |
|
def | __rsub__ (self, other) |
|
def | __mul__ (self, other) |
|
def | __rmul__ (self, other) |
|
def | __or__ (self, other) |
|
def | __ror__ (self, other) |
|
def | __xor__ (self, other) |
|
def | __rxor__ (self, other) |
|
def | __and__ (self, other) |
|
def | __rand__ (self, other) |
|
def | __invert__ (self) |
|
def | __call__ (self, name=None) |
|
def | suppress (self) |
|
def | leaveWhitespace (self) |
|
def | setWhitespaceChars (self, chars) |
|
def | parseWithTabs (self) |
|
def | ignore (self, other) |
|
def | setDebugActions (self, startAction, successAction, exceptionAction) |
|
def | setDebug (self, flag=True) |
|
def | __str__ (self) |
|
def | __repr__ (self) |
|
def | streamline (self) |
|
def | checkRecursion (self, parseElementList) |
|
def | validate (self, validateTrace=[]) |
|
def | parseFile (self, file_or_filename, parseAll=False) |
|
def | __eq__ (self, other) |
|
def | __ne__ (self, other) |
|
def | __hash__ (self) |
|
def | __req__ (self, other) |
|
def | __rne__ (self, other) |
|
def | matches (self, testString, parseAll=True) |
|
def | runTests (self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False) |
|
A variation on L{Literal} which matches "close" matches, that is,
strings with at most 'n' mismatching characters. C{CloseMatch} takes parameters:
- C{match_string} - string to be matched
- C{maxMismatches} - (C{default=1}) maximum number of mismatches allowed to count as a match
The results from a successful parse will contain the matched text from the input string and the following named results:
- C{mismatches} - a list of the positions within the match_string where mismatches were found
- C{original} - the original match_string used to compare against the input string
If C{mismatches} is an empty list, then the match was an exact match.
Example::
patt = CloseMatch("ATCATCGAATGGA")
patt.parseString("ATCATCGAAXGGA") # -> (['ATCATCGAAXGGA'], {'mismatches': [[9]], 'original': ['ATCATCGAATGGA']})
patt.parseString("ATCAXCGAAXGGA") # -> Exception: Expected 'ATCATCGAATGGA' (with up to 1 mismatches) (at char 0), (line:1, col:1)
# exact match
patt.parseString("ATCATCGAATGGA") # -> (['ATCATCGAATGGA'], {'mismatches': [[]], 'original': ['ATCATCGAATGGA']})
# close match allowing up to 2 mismatches
patt = CloseMatch("ATCATCGAATGGA", maxMismatches=2)
patt.parseString("ATCAXCGAAXGGA") # -> (['ATCAXCGAAXGGA'], {'mismatches': [[4, 9]], 'original': ['ATCATCGAATGGA']})