Skip to main content

Timeline for answer to Replace multiple strings with multiple other strings by Slavik Meltser

Current License: CC BY-SA 4.0

Post Revisions

7 events
when toggle format what by license comment
Mar 26, 2022 at 22:27 comment added Slavik Meltser @Sophie sure, everything is possible, it’s programming :) You can try and support also regex as a replacer in the mapObj - which may help you achieve your goal.
Mar 17, 2022 at 23:14 comment added Sophie Hey, nice solution! Is it possible to adapt to tags? example: (find: "<p><figure><img" and replace for "<figure><img" and another's like this
May 9, 2021 at 15:53 comment added Slavik Meltser @AndersonGreen True, you can sort it by size. But it really depends on your use case. Some may prefer to look for shortest first, though. In your case is can be easily solved with Object.keys(mapObj).sort((a,b) => b.length - a.length)
May 3, 2021 at 16:21 comment added Anderson Green This mostly works, except in some cases where the keys overlap. It might work better if the keys in the regex were sorted by length (from longest to shortest).
Apr 30, 2021 at 18:22 comment added Slavik Meltser "dynamically provided mapping" is an unknown content of keys and value and in unknown quantity during the development process. Such information can be known mostly during runtime. E.g. user input.
Apr 30, 2021 at 17:16 comment added Anderson Green What is "dynamically provided mapping?"
Apr 30, 2021 at 17:13 history answered Slavik Meltser CC BY-SA 4.0