javascript, regex parse string content in curly brackets

后端 未结 5 1238
忘掉有多难
忘掉有多难 2020-12-31 03:19

i am new to regex. I am trying to parse all contents inside curly brackets in a string. I looked up this post as a reference and did exactly as one of the answers suggest, h

5条回答
  •  無奈伤痛
    2020-12-31 03:38

    Nothing wrong. But you'll need to look at your capturing groups (the second element in the array) to get the content you wanted (you can ignore the first). To get all occurences, it's not enough to run exec once, you'll need to loop over the results using match.

    Edit: nevermind that, afaik you can't access capturing groups with match. A simpler solution would be using a positive lookahead, as Mike Samuel suggested.

提交回复
热议问题