Next / Previous / Contents / Shipman's homepage

5.34. White: Match whitespace

pp.White(ws=' \t\r\n', min=1, max=0, exact=0)

An instance of this class matches one or more characters of whitespace.

ws

This string argument defines which characters are considered whitespace.

min

This argument defines the minimum number of characters that are required for a match.

max

This argument defines the maximum number of characters that will be matched.

exact

If specified, this number defines the exact number of whitespaces characters that will be matched.

>>> text = '   '
>>> print pp.White().parseString(text)
['   ']
>>> print pp.White(exact=1).parseString(text)
[' ']
>>> print pp.White(max=2).parseString(text)
['  ']