python學習筆記-使用re模板在字符串中查找所有單詞

re模塊的內容

 

re模塊中一些重要的函數:

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']
>>> 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章