您的位置:首页 > 编程语言 > Python开发

python核心编程-正则表达式之match

2016-01-12 22:07 651 查看
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import re
m = re.match('foo','food on the table')  #匹配选择从首个字符开始。
if m is not None:
print m.group() #显示匹配成功的字符串

print '*************************'
m = re.match('foo','xx food on the table')
if m is not None:
print m.group()


输出:

D:\Python27\test>re01.py

foo

D:\Python27\test>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: