var format = /[ `!@#$%^&*()_+-=[]{};':"|,.<>/?~]/;
// ^ ^
document.write(format.test("My@string-with(some%text)") + "<br/>");
document.write(format.test("Mystringwithspaces") + "<br/>");
document.write(format.test("MyStringContainingNoSpecialChars"));
Run code snippetHide results