I have two large corresponding find/replace vectors eg
find = [find1,find2,find3...]
replace = [replace1,replace2,replace3...]
The find and replace vectors contain string vars.
The question is about is the most efficient way to run a complex find/replace all on a large body of text.
I'm currently using a split/join, eg:
var.split(foo).join(bar1))
This works, but (unsurprisingly) as var
gets larger and the find replace vectors get more complicated, the operation slows substantially as var is repeatedly expanded and contracted with each replacement.
I'm considering:
- Switch to a find/replace using regex
- Trying to introduce a bit of async
But I'm interested in what this community knows, or if anyone has tried anything similar and has observations?