importre
list = re.findall('SF:((/w*)*.c$)','SF:/x/eng/rlse/DOT/devN_170820_0500/zephyr/src/libzapid/https_util.c')
print(list)
输出:
[('/x/eng/rlse/DOT/devN_170820_0500/zephyr/src/libzapid/https_util.c', '/https_util')]
,但我只需要:
/x/eng/rlse/DOT/devN_170820_0500/zephyr/src/libzapid/https_util.c
在这种情况下而不是使用Findall,您可以使用搜索并获取相应的组,如下所示
import re
list = re.search('SF:((/w*)*.c$)','SF:/x/eng/rlse/DOT/devN_170820_0500/zephyr/src/libzapid/https_util.c')
print(list.group(1))