Placekey / placekey-js

https://placekey.io
Apache License 2.0
22 stars 4 forks source link

Replace all occurences of replacement words #7

Closed isaacbrodsky closed 4 years ago

isaacbrodsky commented 4 years ago

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.

ibgreen commented 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.

isaacbrodsky commented 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.

I applied this change by creating two replacement maps, each with the regular expressions needed.