python核心编程-正则表达式之-任意单个字符
2016-01-12 22:30
666 查看
#!/usr/bin/env python # -*- coding: UTF-8 -*- import re anyend = '.end' m = re.match(anyend,'bend') if m is not None: print m.group() print '1>>>>>>>>>>>>>>' anyend = '.end' m = re.match(anyend,'\nend') if m is not None: print m.group() print '2>>>>>>>>>>>>>>' anyend = '.end' m = re.search(anyend,'The end.') if m is not None: print m.group() print '3>>>>>>>>>>>>>>' print '-------------------' patt314 = '3.14' pi_patt = '3\.14' m = re.match(pi_patt, '3.14') if m is not None: print m.group() print '1>>>>>>>>>>>>>>' m = re.match(patt314, '3x14') if m is not None: print m.group() print '2>>>>>>>>>>>>>>' m = re.match(patt314, '3.14') if m is not None: print m.group() print '2>>>>>>>>>>>>>>'
输出:
D:\Python27\test>re04.py
bend
1>>>>>>>>>>>>>>
2>>>>>>>>>>>>>>
end
3>>>>>>>>>>>>>>
3.141>>>>>>>>>>>>>>
3x14
2>>>>>>>>>>>>>>
3.14
2>>>>>>>>>>>>>>
D:\Python27\test>
相关文章推荐
- input和raw_input区别
- python学习第二天
- 《笨办法学Python》 第11课手记
- 正则表达式 口诀 学习正则的朋友看看
- python核心编程-正则表达式之-匹配多个字符串
- Python学习手册 - 11
- python核心编程之-search函数
- python核心编程-正则表达式之match
- 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