I want to check if a single character is special in regex.
let char = "?";
if(condition){
console.log("The char is a special character");
}
I want to check if a single character is special in regex.
let char = "?";
if(condition){
console.log("The char is a special character");
}
3
Answers
in a RegExp W represents each special character
definition : W Matches any character that is not a word character from the basic Latin alphabet. Equivalent to [^A-Za-z0-9_].
You can find a list of those characters here :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes