I need a (javascript compliant) regex that will match any string except a string that contains only whitespace. Cases:
" " (one space) => doesn't match
" " (multiple adjacent spaces) => doesn't match
"foo" (no whitespace) => matches
"foo bar" (whitespace between non-whitespace) => matches
"foo " (trailing whitespace) => matches
" foo" (leading whitespace) => matches
" foo " (leading and trailing whitespace) => matches
This looks for at least one non whitespace character.
I guess I’m assuming that an empty string should be consider whitespace only.
If an empty string (which technically doesn’t contain all whitespace, because it contains nothing) should pass the test, then change it to…