py匹配字符串中间的字符串

来源:互联网 发布:数字摇奖软件 编辑:程序博客网 时间:2024/06/13 07:26

python 正则表达式,怎样匹配以某个字符串开头,以某个字符串结尾的情况?

str ="abcdefg123213qwe"

正则表达式:^abc(.*?)qwe$

dbconfig = open("./config.xml", "r")
configStr = dbconfig.read();


pattern = re.compile("<HostName>(.*?)</HostName>")
HostName = re.findall(pattern, configStr)[0]

原创粉丝点击