import re
# Greedy
s = '<html><head><title>Title</title></head></html>'
print(re.match('<.*>', s))
print(re.match('<.*?>', s))
Execution result:
<re.Match object; span=(0, 46), match='<html><head><title>Title</title></head></html>'>
<re.Match object; span=(0, 6), match='<html>'>
Recommended Posts