How to replace text surrounded by tags in javscript?

darkmind

New Member
Assuming I have the following:\[code\]var s = "This is a test of the battle system."\[/code\]and I had an array:\[code\]var array = ["is <b>a test</b>","of the <div style=\"color:red\">battle</div> system"]\[/code\]Is there some function or way I could make it such that I can process the string s such that the output would be:\[code\]var p = "This is <b>a test</b> of the <div style=\"color:red\">battle</div> system."\[/code\]Based on the arbitrary elements in the array?Note that the array elements should be executed in sequence. So looking at the first element in array 1, find the correct place to "replace" in string "s". Then looking at array element 2, find the correct place to "replace" in string "s". Note that the string could contain numbers, brackets, and other characters like dashes (no <> though)
 
Back
Top