python学习笔记-使用re模板在字符串中查找所有单词

re模块的内容

 

re模块中一些重要的函数:

python学习笔记-使用re模板在字符串中查找所有单词_第1张图片

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)