RegEx for Javascript仅允许使用字母数字 [英] RegEx for Javascript to allow only alphanumeric
本文介绍了RegEx for Javascript仅允许使用字母数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要找到一个只允许使用字母数字的注册表。到目前为止,我尝试的每个人只有在字符串是字母数字时才有效,这意味着包含字母和数字。我只想要一个允许两者的东西而不需要两者。
I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just want one what would allow either and not require both.
推荐答案
/^[a-z0-9]+$/i
^ Start of string
[a-z0-9] a or b or c or ... z or 0 or 1 or ... 9
+ one or more times (change to * to allow empty string)
$ end of string
/i case-insensitive
这篇关于RegEx for Javascript仅允许使用字母数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文