我想将字符串拆分成匹配正则表达式模式和不匹配列表的部分的部分。周围的图案python返回匹配和不匹配的字符串模式
例如
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']
这绝对回答了原来的问题。现在,我想知道什么是Pythonic方式来弄清楚*结果列表中哪些元素匹配,哪些不匹配。我需要那个,并且匹配每个元素来检查感觉不仅仅是一点点笨重。 – Jani