Latest

recent

JavaScript RegExp \S Modifier

Definition and Usage

When the \S modifier is set the regular expression finds characters that is not single space characters.
A single space character can be:
  • A whitespace character
  • A tab character
  • A carriage return character
  • A new line character
  • A vertical tab character
  • A form feed character

Syntax

/\S/


Example

In the following code we will do a global search for the characters that is not single space:

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

The marked text below shows where the RegExp gets a match (matches everything except the whitespaces):

Is this all there is?
JavaScript RegExp \S Modifier Reviewed by 1000sourcecodes on 21:48 Rating: 5
Powered by Blogger.