How can I replace a string in parentheses using a regex?

前端 未结 4 1067
春和景丽
春和景丽 2020-12-05 18:16

I have a string:

HLN (Formerly Headline News)

I want to remove everything inside the parens and the parens themselves, leaving only:

<
4条回答
  •  没有蜡笔的小新
    2020-12-05 19:02

    Because parentheses are special characters in regexps you need to escape them to match them explicitly.

    For example:

    "\\(.+?\\)"
    

提交回复
热议问题