diff options
author | ptmcg <ptmcg@austin.rr.com> | 2021-12-03 05:28:22 -0600 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2021-12-06 09:47:22 -0600 |
commit | 1c75c556f7b1ff5470a4d16f4ae05a7c20f89f31 (patch) | |
tree | 3240e8c389f355064bae22eb2f789dde24bc7447 /pyparsing/util.py | |
parent | 514041e01688524332987314892f3110c3f9e614 (diff) | |
download | pyparsing-git-1c75c556f7b1ff5470a4d16f4ae05a7c20f89f31.tar.gz |
Minor enhancement to Word generation of internal regular expression when characters are 2 consecutive chars
Diffstat (limited to 'pyparsing/util.py')
-rw-r--r-- | pyparsing/util.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pyparsing/util.py b/pyparsing/util.py index 1309ad6..34ce092 100644 --- a/pyparsing/util.py +++ b/pyparsing/util.py @@ -213,9 +213,10 @@ def _collapse_string_to_ranges( if first == last: ret.append(escape_re_range_char(first)) else: + sep = "" if ord(last) == ord(first) + 1 else "-" ret.append( - "{}-{}".format( - escape_re_range_char(first), escape_re_range_char(last) + "{}{}{}".format( + escape_re_range_char(first), sep, escape_re_range_char(last) ) ) else: |