JavaScript RegExp \w Metacharacter
JavaScript RegExp Object
Definition and Usage
The \w metacharacter is used to find word characters.
Word characters include: a-z, A-Z, 0-9, and the underscore, including the _ (underscore) character.
Syntax
new RegExp("\w")
Or in a simpler way:
/\w/
Or in a simpler way:
/\w/
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the \w metacharacter
Examples
Examples
Perform a global search for word characters in the string:
var str="Give 100%!";
var patt1=/\w/g;
var patt1=/\w/g;
Below,the markedtext shows the positions where the expression matched:
Give 100%!
Try it yourself »
JavaScript RegExp Object Other Extensions