思路
基本正则模式匹配
ts代码
function repeatedSubstringPattern(s: string): boolean {
let reg: RegExp = /^(\w+)\1+$/
return reg.test(s)
}
console.log(repeatedSubstringPattern(‘abcabcabcabc’))
基本正则模式匹配
function repeatedSubstringPattern(s: string): boolean {
let reg: RegExp = /^(\w+)\1+$/
return reg.test(s)
}
console.log(repeatedSubstringPattern(‘abcabcabcabc’))
评论区