简体   繁体   English

正则表达式是空的空格

[英]regular expression for is empty space

I'm suresomeone of you know how to do this easily, I am trying to validate my inputs that only allows numbers, characters and/or an empty space which mean nothing in a string "" , so I have /^[0-9a-zA-Z]+$/ only missing that empty space in there. 我很遗憾你知道如何轻松地做到这一点,我试图验证我的输入,只允许数字,字符和/或空格,这在字符串""没有任何意义,所以我有/^[0-9a-zA-Z]+$/只缺少那里的空白区域。 Seems I can't find the express for it, so I tried to create a variabel var emptyStr = "" and put it in there but don't really know how to write the correct syntax. 似乎我找不到它的表达式,所以我尝试创建一个varbel var emptyStr = ""并将其放在那里,但实际上并不知道如何编写正确的语法。

Use * rather than + . 使用*而不是+ * is 0 or more times. *是0或更多次。 + is 1 or more times. +是1次或更多次。

/^[0-9a-zA-Z]*$/

/^[A-z0-9\s]*$/

\\s还将捕获空间

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

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