JavaScript RegExp \WMetacharacter
JavaScript RegExp Object
Definition and Usage
The \W metacharacter is used to find non-word characters.
Word characters include: a-z, A-Z, 0-9, and underscore.
Syntax
new RegExp("\W")
Or a simpler way:
/\W/
Or a simpler way:
/\W/
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the \W metacharacter.
Example
Example
Perform a global search for non-word characters in a string:
var str="Give 100%!";
var patt1=/\W/g;
var patt1=/\W/g;
Belowmarkedtext showing the position where the expression gets a match:
Give 100%!
Try it Yourself »
JavaScript RegExp Object Other Extensions