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 non-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 non-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