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

replace()
The replace() method retur " /> 91色在线,国产永久免费,精品久久国产

中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

JavaScript 中的replace方法說明

第一次發(fā)現(xiàn)JavaScript中replace() 方法如果直接用str.replace("-","!") 只會替換第一個匹配的字符.  
而str.replace(//-/g,"!")則可以替換掉全部匹配的字符(g為全局標(biāo)志)。  

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技術(shù)JavaScript 中的replace方法說明,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 中文字幕亚洲精品 | 亚洲精品一区二区二区 | 一区二区三区国产好的精 | 精品国产精品一区二区夜夜嗨 | 亚洲va中文字幕 | 亚洲电影免费 | 亚洲精品中文字幕中文字幕 | 97免费视频在线观看 | 国产精品国产 | 亚洲在线久久 | 日韩一区二区三区视频在线播放 | 韩国精品一区 | 欧美激情精品久久久久久 | 毛片一级片 | 久久岛国| 亚洲一区 中文字幕 | 成人免费视频网站在线看 | 一本岛道一二三不卡区 | 99久久精品免费看国产小宝寻花 | 综合久| 欧美高清视频 | 黄色毛片在线播放 | 自拍视频在线观看 | 欧美白人做受xxxx视频 | 日日操夜夜摸 | 色视频www在线播放国产人成 | 久草网址| 在线日韩不卡 | 久久久精彩视频 | 中文字幕在线看 | 国产成人精品一区二区 | 亚洲一区二区在线 | 久久久久亚洲精品 | 2020国产在线 | 国产精品毛片 | 日本一区高清 | 亚洲网站在线播放 | 免费成人av网站 | 日韩成人高清在线 | 99久久精品免费看国产四区 | 天堂网av在线 |