如何在Javascript中使用正则表达式在匹配中找到匹配项?

时间:2014-09-07 17:43:18

标签: javascript regex

你如何在比赛中找到比赛?

使用以下字符串

@function("something") @anotherFunction("moreStuff" "andMore") "evenMore"

我尝试捕获引号中的内容以及函数名称。我正在寻找的结果是:

匹配1

Group 1: function
Group 2: something
Group 3: undefined

匹配2

Group 1: anotherFunction
Group 2: moreStuff andMore
Group 3: undefined

匹配3

Group 1: undefined
Group 2: undefined
Group 3: evenMore

我可以使用下面的表达式设置引号中的所有内容,但我不确定在查找函数内部存在的匹配时如何捕获正确的组。

\"([^\"]*)\" *

Regular expression visualization

Debuggex Demo

0 个答案:

没有答案
相关问题