Answers for "regex check to see if contains special character"

1

regex to check if string contains special characters javascript

var format = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
//            ^                                       ^   
document.write(format.test("My@string-with(some%text)") + "<br/>");    //true
document.write(format.test("My string with spaces") + "<br/>");        //true 
document.write(format.test("MyStringContainingNoSpecialChars"));       //false
Posted by: Guest on July-05-2020
1

regular expression should not contain special character

//Author: Mohammad Arman Khan
//Regular Expression should not contain Special Characters
var regex = /^[A-Za-z0-9 ]+$/;
Posted by: Guest on January-08-2021

Code answers related to "regex check to see if contains special character"

Code answers related to "Javascript"

Browse Popular Code Answers by Language