Add a question-mark after the *
. Without an question-mark the regular expressions tries to match as many as characters as possible (greedy mode). With the question-mark as little as possible.
/<a.*?>(.*?)<\/a>/ig
Without:
/<a.*>(.*)<\/a>/ig
// ^^^^^ this part matches: <a href="/?an=mb_artist&uid=40574" target="_blank">Maroon 5</a> - <a href="/?an=mb_track&uid=151311">
Demo: http://regex101.com/r/hX1aD1/2
Update:
var myRe = /<a.*?>(.*?)<\/a>/ig;
var myArray;
while ((myArray = myRe.exec(str)) !== null)
{
var content = myArray[1];
// do something with it
}