var regex=/(.).*(\1)/; var str="a sa"; console.log(regex.test(str)); //判断用户输入是否有重复字符 转载于:https://www.cnblogs.com/lansor/p/3286289.html