JavaScript RegExp \S metacharacter
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





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 »
JavaScript RegExp Object