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

replace()
The replace() method retur " /> 九九精品国产亚洲A片无码,51国产午夜精品免费视频,97国产人妻精品无码AV在线

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

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

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

主站蜘蛛池模板: 成人性生交大片免费看中文 | 国产福利视频一区二区 | 啪啪羞羞GIF男女0OXX动态图 | 男人免费网站 | 日日噜噜噜噜夜夜爽亚洲精品 | 久久精品视频在线看99 | 久久久精品免费免费直播 | 可以看的黄页的网站 | 亚洲男人的天堂久久精品麻豆 | 国产探花在线精品一区二区 | 亚洲AV 中文字幕 国产 欧美 | 亚洲AV无码乱码A片无码蜜桃 | 日韩中文亚洲欧美视频二 | 少爷不要别揉了高H | 岛国在线永久免费视频 | 亚洲欧美日韩另类精品一区二区三区 | 99精品国产免费观看视频 | 一级黄色香蕉视频 | 欧美日本高清动作片www网站 | 国产精品亚洲二线在线播放 | 中文字幕视频在线免费观看 | 免费国产成人高清在线看软件 | 国产国拍精品AV在线观看 | 国产精品视频人人做人人爽 | 久久热r在线视频精品 | 精品国产品国语在线不卡 | 久久久久久久久久综合情日本 | 国产精品A久久久久久久久 国产精品A久久777777 | 自拍黄色片 | 欧美一区二区影院 | 午夜小视频免费观看 | 前后灌满白浆护士 | 国产精品嫩草久久久久 | 欧美黑人巨大xxxxx | 亚洲福利视频导航 | 国产伦精品一区二区三区免费 | 99久久99久久久精品久久 | 欧美性黑吊xxx | 久久久大香菇 | 日本xxxxxxx| 漂亮的av女演员 |