正则草稿

r"""<a[\s\S]*?href=("|')(?P<link>http://www.cnblogs.com/lexus/archive/\d{4}/\d{1,2}/\d{1,2}/\d{1,}\.html)\1 """

match = re.search(r"""<a[\s\S]*?href=("|')(?P<link>http://www.cnblogs.com/lexus/archive/\d{4}/\d{1,2}/\d{1,2}/\d{1,}\.html)\1[\s\S]*?>(?P<img>[\s\S]*?)<[\s\S]*?/[\s\S]*?a[\s\S]*?>""", subject)
if match:
# match start: match.start()
# match end (exclusive): match.end()
# matched text: match.group()
else:
# Match attempt failed

你可能感兴趣的:(正则)