Next / Previous / Contents / Shipman's homepage

5.38. ZeroOrMore: Match any number of repetitions including none

pp.ZeroOrMore(p)

An instance of this class matches any number of text items, each of which matches parser p, even if there are no matching items.

>>> someWords = pp.ZeroOrMore(pp.Word(pp.alphas))
>>> print someWords.parseString('Comfidown Majorette')
['Comfidown', 'Majorette']
>>> print someWords.parseString('')
[]
>>> print someWords.parseString('   ')
[]