博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2010年12月24日

摘要: 第一次发现JavaScript中replace()方法如果直接用str.replace("-","!")只会替换第一个匹配的字符.而str.replace(/\-/g,"!")则可以全部替换掉匹配的字符(g为全局标志)。replace()Thereplace()methodreturnsthestringthatresultswhenyoureplacetextmatchingitsfirstargument(aregularexpression)withthetextofthesecondargument(astring).Iftheg(global)flagisnotsetinthereg 阅读全文

posted @ 2010-12-24 17:14 Aason 阅读(10023) 评论(2) 推荐(0)