Closed JohnEarnest closed 8 years ago
Here's the easiest solution in Python-like pseudocode (not a JavaScript person):
new_string = ''
regex = '(string_regex)|(([A-Za-z0-9\]\)])-(\d|(\.\d))|(.)'
for match in regex.findall(string):
data = match.get_text()
if the second and third groups were matched:
data = '$second_group - $third_group
new_string += data
I can work up a PR if wanted.
Making note of an issue brought to my attention by Clynt Pinfold via email. The hack used to deal with the ambiguity of the - operator as a numeric prefix or the verb "negate" is overeager and will alter the contents of string literals if they match the pattern:
The cause is clear; the best resolution less so.