JavaScript RegExp \SMetacharacter

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

The \S metacharacter is used to find non-whitespace characters.

Whitespace characters can be:

  • Space character
  • Tab character
  • Carriage return character
  • New line character
  • Vertical tab character
  • Form feed character

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 a string:

var str="Is this all there is?";
var patt1=/S/g;

Belowmarkedtext shows where the expression gets a match:

Is this all there is?

Try it Yourself »


RegExp 对象参考手册JavaScript RegExp Object Other Extensions