而str.replace(//-/g,"!")則可以替換掉全部匹配的字符(g為全局標志)。

replace()
The replace() method retur " /> 夜色福利视频,国产亚洲精品国产第一,国产激爽大片高清在线观看

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

JavaScript 中的replace方法說明

第一次發現JavaScript中replace() 方法如果直接用str.replace("-","!") 只會替換第一個匹配的字符.  
而str.replace(//-/g,"!")則可以替換掉全部匹配的字符(g為全局標志)。  

replace()  
The replace() method returns the string that results when you replace text matching its first argument  
(a regular expression) with the text of the second argument (a string).  
If the g (global) flag is not set in the regular expression declaration, this method replaces only the first  
occurrence of the pattern. For example,  

var s = "Hello. Regexps are fun.";s = s.replace(//./, "!"); // replace first period with an exclamation pointalert(s); 

produces the string “Hello! Regexps are fun.” Including the g flag will cause the interpreter to  
perform a global replace, finding and replacing every matching substring. For example,  

var s = "Hello. Regexps are fun.";s = s.replace(//./g, "!"); // replace all periods with exclamation pointsalert(s); 

yields this result: “Hello! Regexps are fun!”  

JavaScript技術JavaScript 中的replace方法說明,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 精品午夜久久网成年网 | 91麻豆国产自产 | 久久er国产精品免费观看8 | 视频一区二区中文字幕 | 一区二区在线视频观看 | 一区二区三区免费 | 国产波波社区精品视频 | 91在线蜜桃臀 | 开心丁香婷婷深爱五月 | 午夜国产在线观看 | 亚洲国产欧美91 | 国产精品久久久久毛片真精品 | 国产欧美精品一区二区色综合 | 欧美亚洲高清日韩成人 | 国产原创精品 | 国内精品在线播放 | 亚洲国产精品线播放 | 日韩中文精品亚洲第三区 | 亚洲精品第一国产综合高清 | 成人va视频 | 国产一区美女视频 | 亚洲狠狠 | 成人在线综合网 | 五月婷婷深爱五月 | 日韩精品一区二区三区中文在线 | 欧美日本高清一本二本三本 | 国产精品视频无圣光一区 | 五月婷亚洲 | 在线视频观看亚洲 | 91在线成人 | 婷婷综合五月 | 浮力影院第一页小视频国产在线观看免费 | 5月婷婷6月丁香 | 爽天天天天天天天 | 国产欧美精品专区一区二区 | 免费看一级淫片成人 | 精品亚洲综合在线第一区 | 91色在线播放 | 亚洲欧美一区二区三区不卡 | 国产精选在线播放 | 伊人亚洲综合网 |