在分组的Python正则表达式匹配中需要帮助

下面是模式

MMa,['14', '101'],ND/E/U_C_U,gR,['01','1001'],AD/ME/C_C_U_XT,gBYAR,['290', '1003', '9201', '0202'],BE/RL/U_YW

要求将这些值存储在三组中 即

group 1 = MMa
group 2 = 14,101
group 3 = ND/E/U_C_U
and so on

试试这个

re.finditer(r"(\w+)?(\[\w+(?:\d,\d+)*\],)?([\w/]))",val)
评论