SO - 22504393

by Arun P Johny

JavaScript

var str = "This is 'fisrt text' and now this is 'second', and many more contents goes here.";

var array = ["'some text'",
    "'more text'"],
    i = 0;

var str2 = str.replace(/'.*?'/g, function (str) {
    return array[i++] || ''
});
console.log(str2)