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

replace()
The replace() method retur " /> 欧美日韩网,青青久久,在线天堂av

中文字幕日韩一区二区_国产一区二区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方法說明,轉載需保留來源!

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

主站蜘蛛池模板: 日一日操一操 | 一区二区三区视频在线免费观看 | 蜜桃视频在线观看免费视频网站www | 好姑娘影视在线观看高清 | 成人午夜精品一区二区三区 | 在线黄av | 亚州精品成人 | 精品国产一区二区三区免费 | 欧美久久视频 | 精品欧美久久 | 久久狼人天堂 | 欧美精品综合 | 二区不卡| 欧美一级黄视频 | 天天夜天天操 | 波多野结衣在线观看一区二区三区 | 欧美色影院 | 天天综合网7799精品 | 黄色成人免费在线观看 | 亚洲精品永久免费 | 91精品国产乱码久久久久久久久 | 久久久www成人免费无遮挡大片 | 亚洲天堂中文字幕 | 亚洲精品片| 久久99精品视频 | 免费观看毛片 | 亚洲国产一区二区在线 | 亚洲天堂一区 | 一区二区在线免费播放 | 国产精品免费一区二区三区四区 | 一级欧美一级日韩片免费观看 | 日本欧美大片 | 视频1区 | 精品免费国产视频 | 亚洲女人天堂网 | 91精品国产色综合久久不卡98口 | 欧美成人精品一区二区男人看 | 二区在线视频 | 久久久久香蕉视频 | 不卡一区| 日韩综合网 |