Python正则表达式列表过滤

时间:2016-06-21 15:19:32

标签: python regex list

我有一份清单。我想使用正则表达式将括号'()'中的内容过滤到新列表中。

a = ['avg(time)']

使用正则表达式希望这个

a = time.

1 个答案:

答案 0 :(得分:0)

试试这个,

import re
parathesis_check = re.compile(r'[(]\w+[)]')
parathesis_check.findall('avg(time)')

结果

['(time)']

Demo