开发者

Need a Regular expresssion that should not allow only space in string, It can allow spaces along with characters

Need a Regular expresssion that should not allow only space in str开发者_开发百科ing, It can allow spaces along with characters.

e.g: space+char+space is allowed where as only space is not allowed


/\S/ is sufficient to match a non-empty string.


Try this:

/^\s+$\

Any string that matches the above expression is invalid as per your criteria.


Maybe it's easier and faster to test the emptiness of the string after using trim() on it.


If you're just looking for a positive match:

/\S/

If you want to capture:

/(.*\S.*)/

EDIT:

Actually, if you meant a literal space:

/[ ]/


You simply have to enforce a non-space character appearing at least once:

\s*\S+\s*

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜