Commutation de mots dans une chaîne en utilisant Remplacer

let re = /(\w+)\s(\w+)/;
let str = 'John Smith';
let newstr = str.replace(re, '$2, $1');
console.log(newstr);  // Smith, John
abdelghanyMh