第一个程序
import re
key=r"<h1>hello world <h1>"
p1=r"<h1>.+<h1>"
pattern=re.compile(p1)
print(pattern.findall(key))
['<h1>hello world <h1>']
key=r"aaa@qq.com"
p="aaa@qq.com"
pattern=re.compile(p)
print(pattern.findall(key))
['aaa@qq.com']
“.” 代表可以匹配任意字符
key=r"aaa@qq.com"
p="aaa@qq.com"
pattern=re.compile(p)
print(pattern.findall(key))
['aaa@qq.com']
#将原来的要匹配的字符串中的"."换成其他符号试试
key=r"aaa@qq)com"
p="aaa@qq.com"
pattern=re.compile(p)
print(pattern.findall(key))
['aaa@qq)com']
使用“+”表示可以匹配多个字符
key=r"aaa@qq)))))com"
p="aaa@qq.+com"
pattern=re.compile(p)
print(pattern.findall(key))
['aaa@qq)))))com']
使用“*”表示可以匹配0个或者更多的字符
key=r"http://www.baidu.com & https://www.hao123.com"
p="https*://"
pattern=re.compile(p