1var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
2
3if(format.test(string)){
4 return true;
5} else {
6 return false;
7}
1var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
2// ^ ^
3document.write(format.test("My@string-with(some%text)") + "<br/>"); //true
4document.write(format.test("My string with spaces") + "<br/>"); //true
5document.write(format.test("MyStringContainingNoSpecialChars")); //false
1var email = "grepper@gmail.com";
2if(email.includes("@")){
3 console.log("Email is valid");
4}
5else{
6 console.log("Email is not valid");
7}
8// includes return boolean, if your string found => true else => false