Skip to content


JavaScript 中的replace方法

1第一次发现JavaScript中replace() 方法如果直接用str.replace(“-“,”!”) 只会替换第一个匹配的字符.
2而str.replace(/-/g,”!”)则可以替换掉全部匹配的字符(g为全局标志)。

Posted in JavaScript/DOM/XML, 技术.


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.