python核心编程-正则表达式之-匹配多个字符串
2016-01-12 22:17
871 查看
#!/usr/bin/env python # -*- coding: UTF-8 -*- import re bt = 'bat|bet|bit' m = re.match(bt,'bat') if m is not None: print m.group() print '1>>>>>>>>>>>>>>' m = re.match(bt,'blt') if m is not None: print m.group() print '2>>>>>>>>>>>>>>' m = re.match(bt,'He bit me!') if m is not None: print m.group() print '3>>>>>>>>>>>>>>' m = re.search(bt,'He bit me!') if m is not None: print m.group() print '4>>>>>>>>>>>>>>'
输出:
D:\Python27\test>re03.py
bat
1>>>>>>>>>>>>>>
2>>>>>>>>>>>>>>
3>>>>>>>>>>>>>>
bit
4>>>>>>>>>>>>>>
D:\Python27\test>
相关文章推荐
- 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
- [Leetcode]4. Median of Two Sorted Arrays @python
- 笨办法学Python学习笔记 练习19
- Python 字符串
- 笨办法学Python学习笔记 练习18
- [Leetcode]3. Longest Substring Without Repeating Characters @python