RegExp \ w metacharacter
Definition and Usage
\ W metacharacter is used to find a word character.
Word characters include: az, AZ, 0-9, and underscore that contains _ (underscore) character.
grammar
new RegExp("\w")
或者更简单方式:
/\w/
或者更简单方式:
/\w/
Browser Support
All major browsers support \ w metacharacter
Examples
Examples
In a string of characters in a global search for a word:
var str="Give 100%!";
var patt1=/\w/g;
var patt1=/\w/g;
The marked text below shows where the expression gets a match:
Give 100 %!
try it"
JavaScript RegExp Object