Replace multiple strings with multiple other strings

前端 未结 18 2292
别那么骄傲
别那么骄傲 2020-11-22 04:14

I\'m trying to replace multiple words in a string with multiple other words. The string is \"I have a cat, a dog, and a goat.\"

However, this does not produce \"I ha

18条回答
  •  不要未来只要你来
    2020-11-22 05:08

    user regular function to define the pattern to replace and then use replace function to work on input string,

    var i = new RegExp('"{','g'),
        j = new RegExp('}"','g'),
        k = data.replace(i,'{').replace(j,'}');
    

提交回复
热议问题