js同时替换多个字符串

<script>
    var s="my javascript is very poor,who can help me?"
    var reg=/(\w*)my(.*)is(.*)can(.*)/g
 
    alert(s.replace(reg,"$1his$2was$3could$4"));
 
</script>

参考链接:http://bbs.csdn.net/topics/320097246

posted @ 2017-04-03 22:06  编程创造世界  阅读(10616)  评论(0编辑  收藏  举报