1. 程式人生 > >正則表達式統計字符串中數字的個數

正則表達式統計字符串中數字的個數

div post log pos 則表達式 image pri src find

#coding=utf-8
import string
import re
str=‘i have 300 yuan, you 234 234 give me 200 again, then i have 500 yuan‘
iList= re.findall(r"\d+",str)
print "string:",str
print "total digit number:",len(iList)

技術分享圖片

正則表達式統計字符串中數字的個數