python字符串的查找替换

import re
# Python: 字符串开头或结尾匹配
# str.startswith(),str.endswith()

filename = 'spam.txt'
filename.endswith('.txt')
filename.startswith('file:')

url = 'http://www.python.org'
url.startswith('http:')

######替换相应的字、词
line="this hdr-biz model args= server"
patt=r'args='
name = re.sub(patt, "", line)
print(name)

########字符串的匹配方法
pattern = re.compile(r'\d+') 
it = re.finditer(r"\d+","12a32bc43jf3")
for match in it:
    print (match.group() )
######
line="this hdr-biz model args= server"
patt=r'server'
pattern = re.compile(patt)
result = pattern.findall(line)
print(result)
######
line="this hdr-biz model server"
pattern=r"hdr-biz"
m = re.search(pattern, line)
print(m)
########
line="this hdr-biz 123 model server 456"
pattern=r"123"
matchObj = re.match( pattern, line)
print(matchObj)