findall:通过正则表达式找到字符串中所有想要得字符
text="apple's price $99,orange's price $10" ret=re.findall('$d+',text) print(ret)
sub:替换字符
text="apple's price $99,orange's price $10" ret=re.sub('$d+',"0",text) print(ret)
split:分割函数
text="hello world ni hao" ret=re.split(' ',text) print(ret)
或者:ret=re.split('[^a-zA-Z] ',text)
compile:正则表达式执行很多次,效率低时使用
text="the number is 20.50" r=re.compile('d+.?d*') ret=re.search(r,text)
>>20.50