规则: 找出指定长度的重复的字符串, 未匹配则返回空字符串
function getSameStr(str, n) { //}const res = getSameStr('71235912304', 3)console.log(res) // '123'希望得到结果: '123'
function getSameStr(str, n) { var regExp = new RegExp(`(.{${n}}).*\1`); regExp.test(str); return RegExp.$1; } var result = getSameStr('712359123504', 3) console.log(result) // '123' var result = getSameStr('712359123504', 2) console.log(result) // '12'
1.4m articles
1.4m replys
5 comments
57.0k users