python学习笔记-使用re模板在字符串中查找所有单词
2016-12-07 10:30
615 查看
re模块的内容
re模块中一些重要的函数:
![](http://images.cnitblog.com/blog/311516/201305/20225614-434b1577bb69472dadf5d9e4cef7e28f.png)
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import re
>>> pat = '[a-zA-Z]+'
>>> text = '"hello,my name is xiaoming ,how are you?" he said.'
>>> re.findall(pat,text)
['hello', 'my', 'name', 'is', 'xiaoming', 'how', 'are', 'you', 'he', 'said']
>>>
re模块中一些重要的函数:
![](http://images.cnitblog.com/blog/311516/201305/20225614-434b1577bb69472dadf5d9e4cef7e28f.png)
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import re
>>> pat = '[a-zA-Z]+'
>>> text = '"hello,my name is xiaoming ,how are you?" he said.'
>>> re.findall(pat,text)
['hello', 'my', 'name', 'is', 'xiaoming', 'how', 'are', 'you', 'he', 'said']
>>>
相关文章推荐
- python使用re进行字符串查找和替换
- Python学习笔记之疑问10:如何使用分隔符连接list中的字符串
- python使用re进行字符串查找和替换
- Python----使用正则re查找文本中特定中文字符串
- python3.4学习笔记(十五) 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- Python学习笔记-第三章 使用字符串
- python学习笔记3:使用字符串
- Python下字符串的创建和转义字符的使用 - 千月的python linux 系统管理指南学习笔记(10)
- Python3.x学习笔记[2.5]灵活使用urllib与re
- python学习笔记7(使用字符串)
- python学习笔记3-使用字符串
- Python基础教程 第3章: 使用字符串 学习笔记
- python学习笔记1-字符串的使用
- Python学习笔记一--字符串的使用
- python学习笔记7(使用字符串)
- python学习笔记之二:使用字符串
- python2学习笔记 第三章 使用字符串
- Python 学习笔记(三) 使用字符串
- javascript学习笔记—数组和字符串的使用技巧
- Symfony2 学习笔记之模板使用