python核心编程-正则表达式之-创建字符集合
2016-01-12 22:36
916 查看
#!/usr/bin/env python # -*- coding: UTF-8 -*- import re m = re.match('[cr][23][dp][o2]','c3po') if m is not None: print m.group() print '1>>>>>>>>>>>>>>' m = re.match('[cr][23][dp][o2]','c2do') if m is not None: print m.group() print '2>>>>>>>>>>>>>>' m = re.match('r2d2|c3po','c2do') if m is not None: print m.group() print '3>>>>>>>>>>>>>>' m = re.match('r2d2|c3po','r2d2') if m is not None: print m.group() print '4>>>>>>>>>>>>>>'
输出:
D:\Python27\test>re05.py
c3po
1>>>>>>>>>>>>>>
c2do
2>>>>>>>>>>>>>>
3>>>>>>>>>>>>>>
r2d2
4>>>>>>>>>>>>>>
D:\Python27\test>
相关文章推荐
- 【学神-RHEL7】P4-Python列表操作和字符串的常用方法
- python核心编程-正则表达式之-任意单个字符
- 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原则