White Space

Regular expression to match a white space character.

Usage

var RE_WHITESPACE = require( '@stdlib/regexp/whitespace' );

RE_WHITESPACE

Regular expression to match a white space character.

var bool = RE_WHITESPACE.test( '\n' );
// returns true

bool = RE_WHITESPACE.test( ' ' );
// returns true

bool = RE_WHITESPACE.test( '\\n' );
// returns false

Notes

  • Matches the 25 characters defined as white space ("WSpace=Y","WS") characters in the Unicode 9.0 character database.
  • Matches one related white space character without the Unicode character property "WSpace=Y" (zero width non-breaking space which was deprecated as of Unicode 3.2).

Examples

var RE_WHITESPACE = require( '@stdlib/regexp/whitespace' );

var bool;
var str;

bool = RE_WHITESPACE.test( 'beep boop' );
// returns true

bool = RE_WHITESPACE.test( '\n' );
// returns true

bool = RE_WHITESPACE.test( '\r' );
// returns true

bool = RE_WHITESPACE.test( '\t' );
// returns false

bool = RE_WHITESPACE.test( 'beep' );
// returns false

str = 'This is\na newline\r\ndelimited string.';

var arr = str.split( RE_WHITESPACE );
// returns [ 'This', 'is', 'a', 'newline', '', 'delimited', 'string.' ]