JavaScript RegExp \sMetacharacter
JavaScript RegExp Object
Definition and Usage
The \s metacharacter is used to find 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/
Or a simpler way:
/\s/
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the \s metacharacter.
Examples
Examples
Perform a global search for whitespace characters in a string:
var str="Is this all there is?";
var patt1=/\s/g;
var patt1=/\s/g;
BelowmarkedThe text shows the position where the expression gets a match:
Is this all there is?
Try it Yourself »
JavaScript RegExp Object Other Extensions