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

replace()
The replace() method retur " /> 夜色福利视频,国产亚洲精品国产第一,国产激爽大片高清在线观看

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

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

主站蜘蛛池模板: 巨胸喷奶水www久久久免费观看 | 国产精品自在自线亚洲 | 午夜精品久视频在线观看 | 国产精品福利午夜一级毛片 | 久久精品国产亚洲a | 亚洲综合激情另类专区 | 亚洲精品图区 | 美女扒开屁股让男人桶视频网站 | 久久精品国产99久久 | 色综合天天色综合 | www婷婷 | 永久免费观看视频 | 成人97在线观看免费高清 | 成人精品亚洲 | 91se精品免费观看 | 四虎永久免费在线观看 | 久久久久一 | 精品视频久久 | 韩日成人| 99在线精品日韩一区免费国产 | 亚洲国产中文字幕在线观看 | 国产精品特黄一级国产大片 | 久久国产成人福利播放 | 牛牛本精品99久久精品88m | 天天色综合社区 | 一区二区在线免费视频 | 亚洲欧美一区二区三区国产精品 | 搞av.com| 色久优优 | 色爱区综合激情五月综合色 | 久久中文字幕不卡一二区 | 成人国产精品视频 | 人人干人人爽 | 日本一二三区免费 | 精品免费在线视频 | 一级做受毛片免费大片 | 在线视频一区二区三区在线播放 | 韩国美女免费网站视频 | 日韩视频在线观看一区 | 奇米影视四色7777久久精品 | 91麻豆高清国产在线播放 |