日期:2014-05-16 浏览次数:20385 次
<html>
<body>
<script type="text/javascript">
var str1 = /(\w+)\s*/gi,str2 = /\s*(\w*)\s*(\w*)\s*(\w*)/gi;
name = "Doe, Jo h n";
document.write(name.replace(str1,str2);
</script>
</body>
</html>
<html>
<body>
<script type="text/javascript">
name = "Doe, Jo h n";
alert( name.split(',').reverse() )
</script>
</body>
</html>
var name = "Doe, Jo h n";
document.write(name.split(",").reverse().join());