python regex repetition with capture question

后端 未结 2 1315
庸人自扰
庸人自扰 2021-01-23 03:34

using python3\'s regex capabilities, is it possible to capture variable numbers of capture blocks, based on the number of the repetitions found? for instance, in the following

2条回答
  •  既然无缘
    2021-01-23 04:10

    This will match all the numbers before the dot:

    s = "zzz98zzz67zzz89zzz45vdvd55lplp111.mp3"
    res = re.findall("[0-9]+(?=.*\\.)", s)
    print(res)
    

提交回复
热议问题