let str = `<tag1 name1="value1" name2 = 'value>>>>><<<2'> < tag1 name1="value1"name2 = 'value2<<>>>' >`; let reg = /<\s*?\S+((['"])[^'"]*\2|[^>])*>/gi; console.log(str.match(reg))