?
? ? ? 测试是否含重复字符:
?
? ? ? ? var a = "abcdefga"; ?
var c = "abcdefg"; ? ?
var b = /(\w)\w*\1/;
console.log(b.test(a)) ???//true
? ? ? ??console.log(b.test(c)) ? ??//false
?
\m 表示第m次匹配的内容
?
eg:?
/(span)\1/.test('spanspan')???????? //true
/(span)(div)(td)\1\2\3/.test('spandivtdspandivtd');?? //true
?
?
eg? 匹配xhtml标签? /^<(\w+)\s*.*>.*<\/\1>|<\w+\s*\/>$/.test("<span><img/></span>")