📜  最长的子串 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:05.301000             🧑  作者: Mango

代码示例1
function func(line) {
  let reg = /(\w)\1+/g;
  let longest = line.match(reg).sort((a, b) => {
    a.length - b.length
  }).pop();
  console.log(line + ' : ' + longest);
}

func('ddvvrwwwrggg');
func('sdsffffse');
func('abababaab');
func('aaabbcaaaa');
func('aaaasdfbbbbyyyweryyyuurweuuuuuu');
 Run code snippet