js dynamic insertion and replacement string

replace

str is what I want to query 
loot.SERVE.file is to be replaced content
g global substitution
'' to replace the contents, I have here is empty
str.replace ( new new RegExp (loot.SERVE.file, 'g'), "");

insert

str is content to be replaced
loot.SERVE.file is my content to be replaced
g global substitution
"" To be replaced with the content, I have here is empty

Write a random string STR the let = 'dajkdjcncjdkladjkjcm'
Requirements: Add a SERVE after each j
str.replace(new RegExp('j','g'),"jSERVE");

 

Guess you like

Origin www.cnblogs.com/tlfe/p/11743324.html