I'm a Javascript noob using regex in javascript to globally replace text on web page. Easy enough.
v = v.replace(/\Simon\b/g, "JS Noob");
I know I can replace with functions, but I can't get this to work:
v = v.replace(/\bSimon\b/g, function(replaceLoop) {
var myStringArray = ["herp","derp","clueless","hurrrrr"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++){
replaceLoop = myStringArray;
return replaceLoop;
}
}
I have a feeling I'm thinking about this all wrong.
replaceLoopreturn exactly?