求解Python中一个正则表达式的问题
# -*- encoding:utf-8 -*-'''Created on 2012-8-8@author: Keen'''import urlparsefrom urllib import urlopenimport reregexStr = '[0-9]+'sourceStr = "<html>123</html>"sourceStr2 = "fdasfs5a4f3as1321"print re.findall(regexStr,sourceStr2,0)print re.match(regexStr, sourceStr2,0)regexObj = re.compile(regexStr)matchObj = regexObj.match(sourceStr2)if matchObj: print matchObj.group()
# -*- encoding:utf-8 -*-'''Created on 2012-8-8@author: Keen'''import urlparsefrom urllib import urlopenimport reregexStr = '[0-9]+'sourceStr = "<html>123</html>"sourceStr2 = "fdasfs5a4f3as1321"print re.findall(regexStr,sourceStr2,0)print re.match(regexStr, sourceStr2,0)#not matchprint re.match('[0-9]+', '123abc') , ' match ' #matchregexObj = re.compile(regexStr)matchObj = regexObj.match(sourceStr2)if matchObj: print matchObj.group()