python--正则匹配首尾标签中间的内容
import re it = re.finditer(r"<url>.*?</url>", ‘被筛选字符串‘) # 匹配url标签里的内容 # it = re.finditer(r"<command>.*?</command>", con) # 匹配标签里的内容,有换行符\n导致匹配失败 it2 = re.finditer(r"<command>[\s\S]*?</command>", ‘被筛选字符串‘) # 成功匹配方法1 # it = re.finditer(r"<command>[\d\D]*?</command>", con) # 成功匹配方法2 for match in it: ret = match.group() print(ret) for match in it2: ret = match.group() print(ret)
相关推荐
rojyang 2020-05-11
idning 2020-05-11
chongtianfeiyu 2020-02-16
singer 2020-01-29
waiwaiLILI 2020-01-23
举 2020-01-09
pengkunstone 2019-12-30
georgeandgeorge 2019-12-17
heshanking 2019-08-13
程松 2019-06-29
shijinling0 2019-06-29
ykf 2019-06-29
Kwong 2019-06-27
tmaczt 2019-05-21
81580495 2012-07-06
记昨日书 2012-07-06
Dimples 2019-05-21
albertjone 2019-04-18
echoright晓戈 2018-06-11