summaryrefslogtreecommitdiff
path: root/pyparsing/util.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@users.noreply.github.com>2020-06-20 09:00:04 -0500
committerPaul McGuire <ptmcg@users.noreply.github.com>2020-06-20 09:00:04 -0500
commitaf13023380fe28e2a52f566ea3c8f070fb92f14d (patch)
tree0c05b73d33cc82a6bb000868c7852f84d1da53c2 /pyparsing/util.py
parent788298ecece1fec3ebf06639db646dfa5b170bb8 (diff)
downloadpyparsing-git-af13023380fe28e2a52f566ea3c8f070fb92f14d.tar.gz
strRepr cleanup, remove replicated __str__ methods
Diffstat (limited to 'pyparsing/util.py')
-rw-r--r--pyparsing/util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pyparsing/util.py b/pyparsing/util.py
index 0d5af76..ce68d38 100644
--- a/pyparsing/util.py
+++ b/pyparsing/util.py
@@ -134,7 +134,7 @@ def _escapeRegexRangeChars(s):
return str(s)
-def _collapseAndEscapeRegexRangeChars(s):
+def _collapseStringToRanges(s, re_escape=True):
def is_consecutive(c):
c_int = ord(c)
is_consecutive.prev, prev = c_int, is_consecutive.prev
@@ -149,6 +149,9 @@ def _collapseAndEscapeRegexRangeChars(s):
def escape_re_range_char(c):
return "\\" + c if c in r"\^-][" else c
+ if not re_escape:
+ escape_re_range_char = lambda c: c
+
ret = []
for _, chars in itertools.groupby(sorted(s), key=is_consecutive):
first = last = next(chars)