Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

RegExp \d metacharacter

JavaScript RegExp \d metacharacter

RegExp Object Reference JavaScript RegExp Object


Definition and Usage

The \d metacharacter is used to find digit characters.

Syntax

new RegExp("\\d")



Or a simpler way:



/\d/

Using the modifier:

new RegExp("\\d", "g")



Or a simpler way:



/\d/g


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the \d metacharacter


Example

Example

Perform a global search for digits:

var str="Give 100%!";

var patt1=/\d/g;

The text marked below shows where the expression found matches:

Give

100

%!

Try it »


RegExp Object Reference JavaScript RegExp Object