admin管理员组文章数量:1351946
I have this:
^.*(?!.*[^\S])(?=.*[a-zA-Z]).*$
And this does not match if the string has a space at the end.
I'm trying to make it so that it matches only if the string does not have a space anywhere, not just at the end. How can I do this?
I have this:
^.*(?!.*[^\S])(?=.*[a-zA-Z]).*$
And this does not match if the string has a space at the end.
I'm trying to make it so that it matches only if the string does not have a space anywhere, not just at the end. How can I do this?
Share Improve this question asked Feb 27, 2014 at 22:33 user773737user773737 4- Can you trim leading/trailing spaces before you check the regex? – Joe W Commented Feb 27, 2014 at 22:34
-
4
How about simply:
^[\S]+$
? – Bryan Elliott Commented Feb 27, 2014 at 22:36 -
!/\s/g.test("YOUR STRING");
– Benjamin Gruenbaum Commented Feb 27, 2014 at 22:36 - 1 @MElliott This works. You can get more points if you officially answer the question – user773737 Commented Feb 27, 2014 at 22:37
2 Answers
Reset to default 7How about simply:
^[\S]+$
Working regex example:
http://regex101./r/yA6xU3
Simplest expression to match a non-empty string with no blank characters:
^\S+$
本文标签: javascriptRegex to match if no space is foundStack Overflow
版权声明:本文标题:javascript - Regex to match if no space is found - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743657937a2517452.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论