想要通过正则查找到href开头的且其中包含有httpsvqqcomxcover的href
你可以使用以下正则表达式来查找包含"href"开头且包含"https://v.qq.com/x/cover/"的字符串:
import re
text = 'href="https://v.qq.com/x/cover/123456.html" href="https://www.example.com" href="https://v.qq.com/x/cover/789012.html"'
pattern = r'href="https://v\.qq\.com/x/cover/.*?"'
matches = re.findall(pattern, text)
print(matches)
输出结果为:
['href="https://v.qq.com/x/cover/123456.html"', 'href="https://v.qq.com/x/cover/789012.html"']
这将返回一个包含所有匹配的字符串的列表。
原文地址: https://www.cveoy.top/t/topic/jd5k 著作权归作者所有。请勿转载和采集!