简体   繁体   English

正则表达式匹配“没有空格或没有符号”

[英]Regex to match “no spaces or no symbols”

I am trying to match a password with "no spaces or no symbols" in javascript regex. 我正在尝试在javascript正则表达式中将密码匹配为“无空格或无符号”。

What I tried was: /[^a-zA-Z0-9]|(.*\\s)/g 我试过的是:/ [ /[^a-zA-Z0-9]|(.*\\s)/g )/ /[^a-zA-Z0-9]|(.*\\s)/g

I'm not sure if this is a correct regex. 我不确定这是否是正确的正则表达式。 Can someone help please? 有人可以帮忙吗?

https://regex101.com/r/XKJcTs/1 https://regex101.com/r/XKJcTs/1

^[^\W_]+$

Reject everything that is not alphanumeric and the underscore. 拒绝所有非字母数字和下划线的内容。 Require at least once. 至少需要一次。 This will allow passwords with one character. 这将允许使用一个字符的密码。 You can change the + to {min, max} or to {min,} for no upper limit. 您可以将+更改为{min, max}或更改为{min,}而没有上限。

 ^[^\W_]{3,48}$

https://regex101.com/r/XKJcTs/2 https://regex101.com/r/XKJcTs/2

Taken from this answer https://stackoverflow.com/a/23817519/2604378 从此答案中获取https://stackoverflow.com/a/23817519/2604378

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM