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

replace()
The replace() method retur " /> 欧美人与性禽xxxx,亚洲欧美日韩中文综合在线不卡,久国产视频

一区二区久久-一区二区三区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方法說明,轉載需保留來源!

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

主站蜘蛛池模板: 国产成人综合在线观看网站 | 伊人222成人综合网 伊人22综合 | 亚洲欧美成人综合久久久 | 伊人婷婷色 | 视频三区| 久久青青草原精品无线观看 | 久久99精品久久只有精品 | 成人在线播放视频 | 国产日韩欧美一区二区三区综合 | 在线视频国产一区 | 精品国产自在现线久久 | 国产玖玖在线 | 牛牛本精品99久久精品88m | 丝袜亚洲综合 | 一区二区免费看 | 99精品国产自产在线观看 | 成人年鲁鲁在线观看视频 | 欧美亚洲国产精品第一页 | 午夜在线播放视频 | 久久久久这里只有精品 | 国语对白91 | 国产精品好好热在线观看 | 五月天激情播播 | 97成人在线观看 | 国产精品午夜免费观看网站 | 色久影院 | 91原创视频 | www.xxx欧美| 婷婷激情四射网 | 欧美精品第一页 | 日韩成人免费一级毛片 | 久久夜色精品国产欧美 | 一级毛片特黄久久免费看 | 看全色黄大色黄大片女图片 | 夜色1网站 | 国产日韩一区二区三区在线播放 | 久久精品中文字幕有码日本 | 国产精品麻豆一区二区三区 | 在线看的成人性视频 | 国产精品美女免费视频观看 | 美女一级毛片视频 |