Regular Expression for matching parentheses

前端 未结 5 1472

What is the regular expression for matching \'(\' in a string?

Following is the scenario :

I have a string

str = \"abc(efg)\";
5条回答
  •  庸人自扰
    2020-12-14 00:16

    Two options:

    Firstly, you can escape it using a backslash -- \(

    Alternatively, since it's a single character, you can put it in a character class, where it doesn't need to be escaped -- [(]

提交回复
热议问题