Next / Previous / Contents / Shipman's homepage

5.30. StringEnd: Match the end of the text

pp.StringEnd()

An instance of this class matches only if the text position is at the end of the string.

>>> noEnd = pp.Word(pp.alphas)
>>> print noEnd.parseString('Dorking...')
['Dorking']
>>> withEnd = pp.Word(pp.alphas) + pp.StringEnd()
>>> print withEnd.parseString('Dorking...')
pyparsing.ParseException: Expected end of text (at char 7), (line:1,
col:8)