【发布时间】:2014-06-27 17:04:30
【问题描述】:
我想将字符串拆分为匹配正则表达式模式的部分和不匹配的部分到列表中。
例如
import re
string = 'my_file_10'
pattern = r'\d+$'
# I know the matching pattern can be obtained with :
m = re.search(pattern, string).group()
print m
'10'
# The final result should be as following
['my_file_', '10']
【问题讨论】: