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

RegExp \s metacharacter

JavaScript RegExp \s metacharacter

RegExp Object Reference JavaScript RegExp Object


Definition and Usage

The \s metacharacter is used to find whitespace characters.

Whitespace characters can be:

Syntax

new RegExp("\s")

Or a simpler way:

/\s/


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the \s metacharacter


Example

Example

Perform a global search for whitespace characters in the string:

var str="Is this all there is?";

var patt1=/\s/g;

The text marked below shows where the expression found matches:

Is

this

all

there

is?

Try it »


RegExp Object Reference JavaScript RegExp Object