【问题标题】:Python regex list filtering [duplicate]Python正则表达式列表过滤[重复]
【发布时间】:2016-10-23 05:41:18
【问题描述】:

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

a = ['avg(time)']

使用正则表达式想要这个

a = time.

【问题讨论】:

    标签: python regex list


    【解决方案1】:

    试试这个,

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

    结果

    ['(time)']
    

    Demo

    【讨论】:

      猜你喜欢
      • 2016-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-22
      • 1970-01-01
      • 2015-08-22
      • 1970-01-01
      • 2013-05-19
      相关资源
      最近更新 更多