开发者

Regex including one space

I need to find a regex that will match any string, at开发者_如何学JAVA least 6 characters long, including only one space, but the space can't be the first or the last character. I tried many combinations of \S and \s but I am now stuck. Any help?


Including one or zero spaces:

^(?=.{6,})(\S+\s?\S+)$

If you meant that it must have a space then you should remove the ? in \s?. This will only work in a regex engine that supports positive lookaheads and recognizes the \s and \S sequences. RegexPal


preg_match_all("/[^\s][.*]{6,}[^\s]/", $str, $matches);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜