Next / Previous / Contents / Shipman's homepage

6.6. getTokensEndLoc(): Find the end of the tokens

If used within a parse action, this function takes no arguments and returns the location just after its tokens, counting from 0.

>>> def findEnd(s, loc, toks):
...     print pp.getTokensEndLoc()
... 
>>> letters = pp.Word(pp.alphas).setParseAction(findEnd)
>>> print letters.parseString('pepperpot')
9
['pepperpot']