var names Lennon John nMcCartney Paul nHarrison George nStar Ringo var

1
2
3
4
var names = 'Lennon,John\nMcCartney,Paul\nHarrison,George\nStar,Ringo';
var rex = /([a-z]+), ([a-z]+)/gi;
var str = names.replace(rex, '$2 $1');
console.log(str);