正则表达式


#!/usr/bin/env python
#_*_ coding:utf-8 _*_
__author__ = 'yiyezi'

import re

m = re.match(pattern,data_source)


练习

#!/usr/bin/env python
#_*_ coding:utf-8 _*_
__author__ = 'yiyezi'

import re


#m = re.match("abc","abcdef")
#m = re.match("[0-9]{0,11}","12111111112a2bnfg1sd4")
#m = re.match("[0-9]{8}","12111111112a2bnfg1sd4")
m = re.findall("[0-9]{1,10}","1a2d3df45")
m = re.findall("[a-zA-Z]{1,10}","1a2d3df45")
m = re.findall(".*","1a2d3df45")
m = re.findall(".+","1a2d3df45")
m = re.findall(".","1a2d3df45")
m = re.findall("[a-zA-Z]+","1a_2d*3%d@f45")
m = re.findall("_","1a_2d*3%d@f45")
m = re.search("\d+","1a_2d*3%d@f45")
m = re.sub("\d+","|","1a_2d*3%d@f45")
m = re.sub("\d+","|","1a_2d*3%d@f45",count=2)

#print(m.group)

if m:
    #print(m.group())
    print(m)

部分参数查看alex博客

http://www.cnblogs.com/alex3714/articles/5143440.html