而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方法說明,轉載需保留來源!

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

主站蜘蛛池模板: 久久免费国产精品一区二区 | 四虎影在线永久免费观看 | 精品九九视频 | 久久精品资源 | 一级一级特黄女人精品毛片 | 国产欧美日韩免费一区二区 | 午夜视频国语 | 亚洲天堂成人在线观看 | 99热影院 | 91精品免费高清在线 | 国产精品久久久久久五月尺 | 国内国外精品影片无人区 | 久久精品国产99久久无毒不卡 | 国产一区视频在线免费观看 | 四虎网址| 狠狠色噜噜狠狠狠狠2021天天 | 黄网站在线观看 | 久久成人激情视频 | 国产成人乱码一区二区三区在线 | 亚洲美女一区 | 国产亚洲精品视频中文字幕 | 久久91精品久久91综合 | 最新国产视频 | 青春娱乐国产分类精品二 | 成人午夜免费视频毛片 | 91蜜桃传媒一二三区 | 成人亚洲视频 | 激情综合网五月激情 | 多人伦精品一区二区三区视频 | 亚洲一二区视频 | 97久久曰曰久久久 | 亚洲国产精品久久久久秋霞小 | 国产拳头交一区二区 | 涩涩涩涩涩涩涩涩涩涩 | 欧美www在线观看 | 香蕉成人影院 | 国产精品免费精品自在线观看 | 中文字幕一区二区三区四区五区 | 韩国美女免费网站视频 | 韩国一区二区三区 | 亚洲国产成人久久 |