Latest web development tutorials

RegExp \ W metacharacter

RegExp Object Reference JavaScript RegExp Object

Definition and Usage

\ W metacharacter is used to find a non-word character.

Word characters include: az, AZ, 0-9, and the underscore.

grammar

new RegExp("\W")

或者更简单方式:

/\W/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support \ W metacharacter


Examples

Examples

For non-word character string global search:

var str="Give 100%!";
var patt1=/\W/g;

The marked text below shows where the expression gets a match:

Give 100 %!

try it"


RegExp Object Reference JavaScript RegExp Object