Regular Expression to get a string between parentheses in Javascript

后端 未结 9 809
被撕碎了的回忆
被撕碎了的回忆 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:22

    Ported Mr_Green's answer to a functional programming style to avoid use of temporary global variables.

    var matches = string2.split('[')
      .filter(function(v){ return v.indexOf(']') > -1})
      .map( function(value) { 
        return value.split(']')[0]
      })
    

提交回复
热议问题