diff options
author | ptmcg <ptmcg@austin.rr.com> | 2021-10-24 10:12:45 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2021-10-24 10:12:45 -0500 |
commit | 121a2394ec99f67a641a0d114c31f6f48482031f (patch) | |
tree | 146d8ff5904e1ce245dd6640b90c436582dff24d /pyparsing/core.py | |
parent | a80951bdb0d75c2d7f81a7cd2fda31f7f02d045b (diff) | |
download | pyparsing-git-121a2394ec99f67a641a0d114c31f6f48482031f.tar.gz |
Fixed bug in Word with max argument (#314)
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r-- | pyparsing/core.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py index 26aedd4..960f6fc 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -2680,6 +2680,7 @@ class Word(Token): self.mayIndexError = False self.asKeyword = asKeyword + # see if we can make a regex for this Word if " " not in self.initChars | self.bodyChars and (min == 1 and exact == 0): if self.bodyChars == self.initChars: if max == 0: @@ -2687,7 +2688,10 @@ class Word(Token): elif max == 1: repeat = "" else: - repeat = "{{{}}}".format(max) + repeat = "{{{},{}}}".format( + self.minLen, + "" if self.maxLen == _MAX_INT else self.maxLen + ) self.reString = "[{}]{}".format( _collapseStringToRanges(self.initChars), repeat, |