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

replace()
The replace() method retur " /> 成人黄色免费在线观看,亚久久伊人精品青青草原2020,一级毛片视频在线

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

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

主站蜘蛛池模板: 在线欧美a| 国产一区二区三区国产精品 | 五月婷婷丁香综合 | 天天色综合久久 | 黄色网页在线播放 | 91青青| 亚洲免费小视频 | 女的毛片毛片毛毛片毛毛毛毛片 | 另类图片综合网 | 亚洲免费小视频 | 色狠狠色狠狠综合天天 | 中文字幕久久亚洲一区 | 一二三区免费视频 | 很黄很暴力深夜爽爽无遮挡 | 久久精品国产亚洲综合色 | 不良网站在线观看 | 国产精品色婷婷在线观看 | 起碰97| 国产精品久久久久免费视频 | 久久久久久久91精品免费观看 | 91久久综合 | 91中文字幕视频 | 国产综合在线观看视频 | 中文字幕视频网 | 男女视频在线观看免费高清观看 | 国产亚洲精品一品区99热 | 94欧美setu | 日韩高清一区二区三区五区七区 | 91在线视频福利 | 激情综合丁香 | 久久精品免视看国产成人2021 | 一区二区三区免费在线观看 | 美国色视频 | 婷婷免费视频 | 丁香六月婷婷激情 | 色老板免费观看在线播放 | 六月丁香婷婷激情 | 中文字幕无线码中文字幕免费 | 日本特黄色 | 久久91精品国产91久久户 | 久久91精品综合国产首页 |