摘要:
这里主要介绍Python中常用的正则表达式处理函数。re.match re.match 尝试从字符串的开始匹配一个模式,如:下面的例子匹配第一个单词。import re
text = "JGood is a handsome boy, he is cool, clever, and so on..."
m = re.match(r"(\w+)\s", text)
if m:
print m.group(0), '\n', m.group(1)
else:
print 'not match' re.match的函数原型为:r 阅读全文