How to use the regular expression\ W metacharacter
This article is about how regular expressions\ W metacharacters are used. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Regular expression\ W metacharacter:
\ W (uppercase) is used to match non-word characters, which is equivalent to "[^ a-zA-Z0-9]".
Grammatical structure:
Constructor mode:
New RegExp ("\\ W")
Object direct quantity method:
/\ W /
Browsers support:
IE browsers support this metacharacter.
Firefox browser supports this metacharacter.
Google browser supports this metacharacter.
Example code:
Example 1:
Var str= "antzonelove"; var reg=new RegExp ("\\ W", "g"); console.log (str.match (reg))
The above code matches all characters except word characters.
Example 2:
Var str= "antzonelove"; var reg=/\ Whampg; console.log (str.match (reg)); Thank you for reading! This is the end of the article on "how to use regular expressions\ W metacharacters". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!