The Mozzila website provides an example with regular expressions:
var re = /(\w+)\s(\w+)/; var str = 'Джон Смит'; var newstr = str.replace(re, '$2, $1'); console.log(newstr); It is said that the example will print "Smith, John." But in my browsers the latest versions of chrome and firefox persist John Smith. What I do not understand, please explain, or do something wrong?