I'm still learning regexp and I was wondering what the regexp would look like for detecting a string with at least 6 characters and without any whitespace?
I'm using javascript, so why doesn't this work?
if (VAL.match( /^\S{6,}$/) ) ret开发者_如何学Pythonurn true;
You can match a whitespace character with a \s
, and a non-whitespace character with \S
. So this should work for you:
/^\S{6,}$/
However you didn't specify the flavor of regex you're using. You may need to escape the bracket or use another character class if \S
is not available.
EDIT (Lars): The question was "at least 6 characters" - modified to {6,}
Try the following regex:
/^\S{6,}$/
精彩评论