function aChange(a) { let matchV = a.match('rel="opener"') let b= /<(a)[^>]*>.*?|<.*? />//gi console.log('matchV: ', matchV, matchV&&matchV.length) let matchA = a.match(b) console.log('matchA: ', matchA) return a } let a = '<a>111</a>' let t = '<a rel="opener" target="_blank" href="http://localhost:8082/rms/pc/#/myProject/myProject" style="color: #386dff;">http://localhost:8082/rms/pc/#/myProject/myProject</a>' // console.log(aChange(t)) console.log(aChange(a))