<p>I'd like to find the string between the two paragraph tags.</p><br><p>And also this string</p>
我如何获得前两个段落标签之间的字符串?然后,如何获取第二段标签之间的字符串?
原文由 Zorgan 发布,翻译遵循 CC BY-SA 4.0 许可协议
<p>I'd like to find the string between the two paragraph tags.</p><br><p>And also this string</p>
我如何获得前两个段落标签之间的字符串?然后,如何获取第二段标签之间的字符串?
原文由 Zorgan 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果你想要 p 标签之间的字符串( 不包括 p 标签)然后添加括号到 .+? 在 findall 方法中
import re
string = """<p>I'd like to find the string between the two paragraph tags.</p><br><p>And also this string</p>"""
subStr = re.findall(r'<p>(.+?)</p>',string)
print subStr
结果
["I'd like to find the string between the two paragraph tags.", 'And also this string']
原文由 Rich Rajah 发布,翻译遵循 CC BY-SA 4.0 许可协议
2 回答5.1k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
1 回答1.7k 阅读✓ 已解决
1 回答1.2k 阅读✓ 已解决
常用表达
以下是您在控制台中运行的文本。