python - 正则表达式查找所有字符串和介于两者之间的任何字符的链接
问题描述
我有一个这样的文本摘录(原始文本很长,超链接交错排列):
... <div> <a href=\n=3D"https://www.wonder.com/alerts/remove" style=3D"text-decoration:none;color:#427fed">Unsu=\nbscribe</a> <span style=3D"padding:0px 4px 0px 4px;color:#252525">|<a href=3D"https:=\n//www.wonder.com/url?rct=3Dj&sa=3Dt&></span> =\n<a href=3D"https://www.wonder.com/alerts?source=3Dalertsmail&hl=3Den&=\namp;gl=3DIN&msgid=3DMTA2MzYwOTAxMTQ5NzI4MTc3MTE" style=3D"text-decorati=\non:none;color:#427fed"> View all your alerts </a> </div> </td> </tr> <tr> <=\ntd style=3D"padding:6px 10px 0px 0px;font-family:Arial"> <a href=3D"https:/=\n/www.wonder.com/alerts/feeds/065638/93686812" styl=\ne=3D"text-decoration:none;color:#427fed">...
我正在尝试提取此超链接(不一定是最后一个):https:/=\n/www.wonder.com/alerts/feeds/065638/93686812
我不知道 '=' 将出现在链接中的什么位置。所以尝试使用这样的积极前瞻:
re.match(r'(?=\=)\"https(.*).*\"', text)
这没有帮助。建议请。
另外,有没有一种方法可以定义一个存在字符串的列表,然后匹配一个包含所有这些字符串的字符串?我看到了几篇关于匹配列表中的任何内容的帖子,而不是全部。我试图寻找一种类似(https)&(wonder)&(alerts)&(feeds)
但运气不佳的模式。
解决方案
这对我有用:
(\"https([^\"])*\d+\")
推荐阅读
- python - Python 的 Serial 返回什么类型的 unicode?无法在 Python2.7 中解码(奇怪的输出)
- typescript - TypeScript 阻止文件成为模块?
- java - 在一个请求中设置多个参数
- mysql - 即使新值相同,MySQL“ON DUPLICATE KEY UPDATE”是否也会替换该值?
- sql - 如何返回达到某个阈值的日期
- node.js - 如何在基于 Debian 的映像(Dockerfile)中安装 Node.js 版本 16.xx?(为什么这么难?)
- jquery - JSX 和 JQuery 未定义变量
- javascript - 如何使用“framer-motion”创建与标签无关的组件实用程序?
- c++ - 使用 0.5 libyaml-cpp-dev 构建失败并出现 boost 错误
- r - Cox回归HR分组