zhaoyingjie

python匹配两个字符串中间的字符串

问题:使用python正则如何匹配两字符串中间的字符串
解决:使用re模块的findall,注意,re.match是只能从开头匹配的
方法:

import re
html_str = \'</a></div></div><script>var Locafds fds fds fds fds fds fds ;</script></body></html>\'
local = re.findall(r\'</div><script>(.*)</script></body>\', html_str)
print(local[0])
#\'var Locafds fds fds fds fds fds fds ;\'

 



这样就可以匹配到script标签中的代码了

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2021-12-14
  • 2021-07-01
  • 2021-09-10
  • 2021-10-09
  • 2021-09-09
  • 2021-09-27
  • 2021-12-22
猜你喜欢
  • 2018-10-31
  • 2021-11-13
  • 2021-11-18
  • 2021-10-09
  • 2021-09-07
  • 2021-09-05
  • 2021-11-27
相关资源
相似解决方案