【问题标题】:How to match text or numbers inside parenthesis?如何匹配括号内的文本或数字?
【发布时间】:2014-05-23 04:14:42
【问题描述】:

我正在寻找与数字和括号匹配的公式。

"Please answer your name of bank.(1) (bank of america)"

对于(1),我使用了\d([1]) 对于(bank of america),我想出了\*([a-b])

【问题讨论】:

标签: javascript python regex match


【解决方案1】:

您必须在此处转义 () 字符。正则表达式是:

\(1\) \([^)]+\)

使用 Python 进行示例测试:

s = "Please answer your name of bank.(1) (bank of america)"
print re.findall('\(1\) \([^)]+\)', s)

输出:

['(1) (bank of america)']

【讨论】:

    猜你喜欢
    • 2023-03-15
    • 1970-01-01
    • 2013-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-24
    • 2010-09-25
    • 1970-01-01
    相关资源
    最近更新 更多