Next / Previous / Contents / Shipman's homepage

6.16. replaceWith(): Substitute a constant value for the matched text


If you attach this function to a parser as a parse action, when the parser matches some text, the value that will be deposited in the ParseResults will be the literal string value.

>>> password = pp.Word(pp.printables).setParseAction(
...     pp.replaceWith('********'))
>>> print password.parseString('shazam')
>>> print password.parseString('abracadabra')