#!/usr/bin/env python3.4
#coding:utf-8
import re
pattern = "text"
text = "Dose this text match the pattern?"
match = re.search(pattern, text)
s = match.start()
e = match.end()
print("Found '%s'\nin '%s'\nfrom %d to %d ('%s')" % (match.re.pattern, match.string, s, e, text[s:e]))
正则--re.search
最新推荐文章于 2022-09-04 21:49:28 发布