let str = '<a href="http://www/baidu.com">百度</a>';
// 提取 url 和 文本
const reg = /<a href="(.*)>(.*)<\/a>/;
const result = reg.exec(str);
console.log(result)

二. 正则命名分组 exec

let str2 ='<a href="http://www.baicu.com">百度</a>';
// 提取 url 和 文本
const reg2 = /<a href="(?<url>.*)">(?<text>.*)<\/a>/;
const result2  =reg2.exec(str2)

二. 正则命名分组 exec

相关文章:

  • 2022-12-23
  • 2021-10-16
  • 2021-11-21
  • 2021-12-07
  • 2021-11-24
  • 2022-12-23
  • 2022-01-14
  • 2021-09-09
猜你喜欢
  • 2021-06-01
  • 2021-05-20
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2022-03-07
相关资源
相似解决方案