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

replace()
The replace() method retur " /> 2020国产精品永久在线观看,亚洲欧美韩日,免费在线观看a

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

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

主站蜘蛛池模板: 一级亚洲 | 69国产成人精品午夜福中文 | 深爱五月激情网 | 久久久久久午夜精品 | 九九久久精品国产 | www.五月婷婷.com | 精品国产a | 成人a毛片一级 | 婷婷激情四射网 | 91av国产视频 | 日韩在线视频中文字幕 | 狠狠狠地在啪线香蕉 | 日韩123| 国产男女爱视频在线观看 | 成人午夜大片免费7777 | 视频在线观看一区二区 | 欧美人与禽交片在线播放 | 日本一区二区在线免费观看 | 2021国产视频 | 国产精品对白刺激 | 日韩亚洲精品不卡在线 | 香蕉久热 | 国产99对白在线播放 | 黄网站在线观看高清免费 | 高清成年美女黄网站色大 | 爱啪精品导航在线 | 999热精品这里在线观看 | 91视频播放 | 午夜性色视频 | 白白在线成人永久视频 | 免费看美女毛片 | 色婷婷在线视频观看 | 国产成人在线看 | 亚洲综合插插 | 美女网站黄色 | 国产在线观看精品一区二区三区91 | 国产中文99视频在线观看 | 黄视频入口 | 日本午夜vr影院新入口 | 风间由美一区二区播放合集 | 一本色道久久综合狠狠躁 |