Closed isaacbrodsky closed 4 years ago
You could build a global regex (new Regex()
with /g
option) as well and do it in one operation. Presumably more efficient especially if multiple matches. But I think this is OK.
You could build a global regex (
new Regex()
with/g
option) as well and do it in one operation. Presumably more efficient especially if multiple matches. But I think this is OK.
I applied this change by creating two replacement maps, each with the regular expressions needed.
This accounts for a difference in Python and JavaScript replace functions. There is a built-in replaceAll function but it is not available in Node 12.