javascript正则获取a标签的href

js正则获取a标签的href

let str = '<a href="https://www.test.com" >test</a>'
let reg = /((\w+):\/\/)?([\w.]+[.]{1})[\w]+/
console.log(str.match(reg)[0])

 

posted @ 2021-06-16 11:51  李照耀  阅读(2624)  评论(2编辑  收藏  举报