我需要一个(符合javascript标准的)正则表达式,它能匹配任何字符串,但不包括只包含空格的字符串。以下是示例:
" " (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
if(str.trim()){ //匹配 }
。 - Shmiddty