python匹配两个字符串中间的字符串,python匹配,问题:使用pytho


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

import rehtml_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标签中的代码了

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

评论关闭