[英]what is javascript regex to validate an array of string value
我想使用正则表达式验证字符串类型的单个元素的数组。 数组不能为空,并且不能以任何特殊符号开头(#除外),并且字符串只能包含数字和字母。
我尝试了什么[a-zA-z0-9s!@#$%^&*()_ / \\ + =。,〜`] +
你可以试试
regex = /^#?[a-zA-Z0-9]+/gm;
尝试这个:
regex = /^#?[a-z0-9]+/gi;
分解:
/^ - Match the start of the string
#? - Match an optional #
[a-z0-9] - Character set including the lowercase alphabet, and all ten digits
+ - Match one or more of the preceding character set
/gi - Global and case-insensitive flags
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.