【发布时间】:2019-08-06 06:03:47
【问题描述】:
我有一个只允许使用字母、数字、空格或连字符的正则表达式。但是,我想禁止用户执行以下操作:
hello--world Have more than one hyphen sitting next to each other
--hello Have a hyphen in the beginning. It must have a number or letter first
我该如何做到这一点?我当前的正则表达式如下所示:
let alphanumericTest = new RegExp("^\s*([0-9a-zA-Z- ]*)\s*$");
【问题讨论】:
标签: javascript jquery regex