我有以下文字:
var text=
"The sad sad man uses a bat to swing the bats
away from his sad garden .
Sadly he doesn't succeed. "
假设我想搜索这个词"sad"
。
var match;
re = /sad/g,
match;
while (match = re.exec(text)) {
console.log(match);
match.poz = ....
}
我怎样才能成为一个从 0,0 开始match.poz
的元组(数组) ?[line,position on the collumn]
例如。
- 1 场比赛 --> match.poz = [0,4]
- 2 匹配 --> match.poz = [0,8]
- 3 场比赛 --> match.poz = [1,14]
- 4 匹配 --> match.poz = [2,0]