首页 > 代码库 > python 正则小例子

python 正则小例子

 1 import  re 2  3 s1 = 1 (021)8567895 90 4 s2 = 1 021-5689564 90 5 s3 = 1 021 4886542 90 6 s4 = 1 0218567899 90 7 s5 = module-layout=\"layout-d\">\n  \n \n\n<link  8 s6 = module-layout=\"layout-d\n<link  9 m1 = re.findall(r\(\d{3}\)\d{7,8},s1)10 m2 = re.findall(r\d*-\d{7,8},s2)11 m3 = re.findall(r\d{2,3}[ -]?\d{1,10},s4)12 m5 = re.findall(rmodule-layout=.*,s6,re.S)#re.S 让  .  匹配换行符

 

python 正则小例子