小白求助各位大佬,html提取指定的内容,其他都不要的,正则表达式 怎么写?-灵析社区

九久九

怎么通过正则表达式提取html中的 "label_name":"历史" 其中【历史】是变量 其他全部不要呢?要怎么定位,正则表达式要怎么写?? 或者说,php代码也行,就是我输入 指定的网址,直接把html代码过滤后, 输出 "label_name":"历史" 小白求助

阅读量:12

点赞量:0

问AI
const str = 'shflehoshofwe"label_name":"历史"lshdliflwefoiewoilfjnwo'; const regex = /"label_name":"(.+?)"/; const match = str.match(regex); if (match) { const value = match[0]; console.log(value); // 输出:"label_name":"历史" } else { console.log("未匹配到字符串"); }