var data = []; 'Username:1hfjdjdk<BR>Password:ahdgdgdg<BR>Username:1hfjdjdk<BR>Password:ahdgdgdg'.replace(/Username:([^<]+)<BR>Password:([^<]+)/g, function(match, username, passwd) { data.push([username, passwd]); }); alert(data.join('\n'));