python 正则替换

20.5.101.31_/root>cat aa.py 
import re
str='/app/esb/esblog/in/20180828/0700100003502.log.10:2018-08-28 00:00:10,650 [esbapp3-esb_in-20180828000010-261288] [pool-5-thread-1535]'
result,number=re.subn('/app/esb/esblog/in/[0-9]{1,}/[0-9]{1,}.log.[0-9]{1,}:','',str)
print result
20.5.101.31_/root>python aa.py
2018-08-28 00:00:10,650 [esbapp3-esb_in-20180828000010-261288] [pool-5-thread-1535]
20.5.101.31_/root>
原文地址:https://www.cnblogs.com/hzcya1995/p/13349099.html