Regular Expression to get a string between parentheses in Javascript

后端 未结 9 764
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 09:45

I am trying to write a regular expression which returns a string which is between parentheses. For example: I want to get the string which resides between the strings \"(\"

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 10:12

    Simple solution

    Notice: this solution can be used for strings having only single "(" and ")" like string in this question.

    ("I expect five hundred dollars ($500).").match(/\((.*)\)/).pop();
    

    Online demo (jsfiddle)

提交回复
热议问题