I got confused in the array returned by the regex when using both / g (to get multiple matches) and parentheses (to get backlinks). I don’t understand how to get backlinks, because the index array of matches seems to refer to multiple matches, not backlinks.
eg:
string = "@abc @bcd @cde";
re2 = '@([a-z]+)';
p = new RegExp(re2,["g"]);
m = string.match(p)
for (var i in m) { alert(m[i]; }
it returns "@abc", "@bcd", "@cde"
but I want it to return"abc", "bcd", "cde"
how do i get the latest?
source
share