summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2017-03-03 01:07:56 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2017-03-03 01:07:56 +0000
commit51d6e9584265da40f52bf57ae63cf10f7c660533 (patch)
tree514e8b1ae7d900c8cd08e4edd483b0e3e1dea8f5
parent2cf33fcefb1dace6ec1d714368c20aaf89656692 (diff)
downloadpyparsing-51d6e9584265da40f52bf57ae63cf10f7c660533.tar.gz
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
-rw-r--r--src/pyparsing.py6
1 files changed, 5 insertions, 1 deletions
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 ) ])