I’m having trouble replacing things like “joe.” in a regular expression. Here’s the code
var objects = new Array("joe","sam");
code = "joe.id was here so was sam.id";
for(i = 0; i < objects.length; i++) {
re = new RegExp(objects[i]+"\.", "g");
code = code.replace(re, "stan ");
}
I’ve tried \., \\., \\\., but none of those seem to work.
Your code works perfectly with
"\\.""\\."creates the string\., which fits the bill.