Created
April 6, 2012 18:23
-
-
Save beakr/2321854 to your computer and use it in GitHub Desktop.
Telling if the entire string consists of an item (whitespace in this case)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var re = /^\s+$/; | |
/* | |
* ^ - start of string | |
* \s - anything whitespace | |
* + - 1 or more | |
* $ - the end of the string | |
*/ | |
if (" ".match(re)) { | |
alert("The string is all whitespace!"); | |
} | |
//=> The string is all whitespace! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment