Home | Trees | Indices | Help |
|
---|
|
object --+ | ParserElement --+ | ParseElementEnhance --+ | _MultipleMatch --+ | OneOrMore
Repetition of one or more of the given expression.
Parameters:
None
) - expression for a terminating
sentinel (only required if the sentinel would ordinarily match the
repetition expression)
Example:
data_word = Word(alphas) label = data_word + FollowedBy(':') attr_expr = Group(label + Suppress(':') + OneOrMore(data_word).setParseAction(' '.join)) text = "shape: SQUARE posn: upper left color: BLACK" OneOrMore(attr_expr).parseString(text).pprint() # Fail! read 'color' as data instead of next label -> [['shape', 'SQUARE color']] # use stopOn attribute for OneOrMore to avoid reading label string as part of the data attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stopOn=label).setParseAction(' '.join)) OneOrMore(attr_expr).parseString(text).pprint() # Better -> [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'BLACK']] # could also be written as (attr_expr * (1,)).parseString(text).pprint()
Instance Methods | |||
|
|||
Inherited from Inherited from Inherited from |
Static Methods | |
Inherited from |
Class Variables | |
__slotnames__ =
|
|
Inherited from |
Method Details |
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 | http://epydoc.sourceforge.net |