Javascript Regular Expressions Switch two words

Description

Javascript Regular Expressions Switch two words


let name = "CSS HTML";
let re = /^(\w+)\s(\w+)$/;
let newname = name.replace(re,"$2, $1");

console.log(newname);/*from   www .  j  av  a  2  s . c o  m*/



PreviousNext

Related