Forum Moderators: open
[pre]function special(xStr){
var lt=/</g;
var gt=/>/g;
xStr=xStr.replace(lt,"<");
xStr=xStr.replace(gt,">");
return xStr;
}[/pre] That's just a primitive example I knocked up that will convert all opening and closing pointy-brackets in a string given to that function. There is no doubt a more efficient and scalable way to write this, but it embodies the basic principle.
Cheers,
D.
[pre]function special(xStr){
var entArray=new Object();
entArray["<"]=/</g;
entArray[">"]=/>/g;
for(x in entArray)xStr=xStr.replace(entArray[x],x);
return xStr;
}[/pre] Just keep adding to the associative array for each character you want to replace.
Cheers,
D.