const regex = /(..+)(?=.*?(\1))/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(..+)(?=.*?(\\1))', 'gm')
const str = `0z8b816ne139z1b948bjk50f9498t139gjj90t7tb3509w6h0r7tbp
`;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
1条答案
按热度按时间gkn4icbw1#
正则表达式:
(..+)(?=.*?(\1))
的数据
参考文献
字符串