Skip to content

Files

Latest commit

78ff400 · Sep 9, 2018

History

History

whitespace

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 2, 2018
Apr 8, 2017
Sep 9, 2018
Mar 18, 2018
Feb 2, 2018
Sep 9, 2018
Nov 2, 2017

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 true

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.' ]