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

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

主站蜘蛛池模板: 国产一区二区三区在线影院 | 91专区在线观看 | 精品国产一区二区三区不卡在线 | 91伊人影院| 一区二区三区四区精品 | 九九综合视频 | 国产综合在线观看视频 | 夜夜未满十八勿进的爽爽影院 | 91网站网址最新 | 天天操天天干天天爽 | 天天做.天天爱.天天综合网 | 成人精品视频网站 | 91年精品国产福利线观看久久 | 91高清国产视频 | 91嫩草视频在线观看 | 国产一区二区三区高清 | www.欧美黄色 | 欧美色tv | 91在线九色 | 精品成人 | 久久成人小视频 | 一区二区高清视频在线观看 | 一区二区视频在线播放 | 日本人乱人乱亲乱色视频观看 | 亚洲激情综合网 | 国产精品一区不卡 | 中文字幕永久免费视频 | 免费国产视频 | 一色屋色费精品视频在线观看 | 91福利视频免费观看 | 在线加勒比 | 久青草国产在线视频亚瑟影视 | 2021久久精品国产99国产精品 | a亚洲视频| 亚洲视频1 | 在线综合色| 欧美一卡2卡3卡4卡无卡网老狼 | 欧美三级免费观看 | 欧美三级黄色 | 福利观看| 伊人久久国产精品 |