diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2017-03-03 01:07:56 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2017-03-03 01:07:56 +0000 |
commit | cb6fdd1d2211930b9f2a0263ece359778595f885 (patch) | |
tree | 514e8b1ae7d900c8cd08e4edd483b0e3e1dea8f5 | |
parent | 2a15a07e755b2acb18b76d87105253dc420acce8 (diff) | |
download | pyparsing-git-cb6fdd1d2211930b9f2a0263ece359778595f885.tar.gz |
Fix error and expand docstring examples for ParserElement.searchString
-rw-r--r-- | src/pyparsing.py | 6 |
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 ) ])
|