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>
相关文章推荐
- Python入门
- python 列表总结
- Python Division //
- python中对文件、文件夹(文件操作函数)的操作
- python selenium的模拟点击,模拟滑动等操作
- Python Division and Remainders
- python爬取知乎话题的精华问题下的用户信息
- 笨方法学python学习笔记 练习20
- Python学习手册 - 10
- python的LEGB原则
- python exception
- [Leetcode]5.Longest Palindromic Substring @ Python
- [Leetcode]4. Median of Two Sorted Arrays @python
- 笨办法学Python学习笔记 练习19
- Python 字符串
- 笨办法学Python学习笔记 练习18
- [Leetcode]3. Longest Substring Without Repeating Characters @python
- 深入思考python的super()
- ubuntu14下python3.4安装PIL的步骤
- python数字图像处理(10):图像简单滤波