return mystring.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/; // ^ ^ document.write(format.test("My@string-with(some%text)") + "<br/>"); document.write(format.test("My string with spaces") + "<br/>"); document.write(format.test("MyStringContainingNoSpecialChars"));