From 51d6e9584265da40f52bf57ae63cf10f7c660533 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Fri, 3 Mar 2017 01:07:56 +0000 Subject: Fix error and expand docstring examples for ParserElement.searchString git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@458 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b --- src/pyparsing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pyparsing.py b/src/pyparsing.py index 933cf63..d22c683 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -1758,8 +1758,12 @@ class ParserElement(object): cap_word = Word(alphas.upper(), alphas.lower()) print(cap_word.searchString("More than Iron, more than Lead, more than Gold I need Electricity")) + + # the sum() builtin can be used to merge results into a single ParseResults object + print(sum(cap_word.searchString("More than Iron, more than Lead, more than Gold I need Electricity"))) prints:: - ['More', 'Iron', 'Lead', 'Gold', 'I'] + [['More'], ['Iron'], ['Lead'], ['Gold'], ['I'], ['Electricity']] + ['More', 'Iron', 'Lead', 'Gold', 'I', 'Electricity'] """ try: return ParseResults([ t for t,s,e in self.scanString( instring, maxMatches ) ]) -- cgit v1.2.1