Regular Expression for matching parentheses

前端 未结 5 1455

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:23

    Because ( is special in regex, you should escape it \( when matching. However, depending on what language you are using, you can easily match ( with string methods like index() or other methods that enable you to find at what position the ( is in. Sometimes, there's no need to use regex.

提交回复
热议问题