切换布局
显示结果
<html> <head> <title>JavaScript String replace() Method</title> </head> <body> <script type = "text/javascript"> var re = /(\w+)\s(\w+)/; var str = "zara ali"; var newstr = str.replace(re, "$2, $1"); document.write(newstr); </script> </body> </html>