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

replace()
The replace() method retur " /> 久久久久久av,国产高清精品一区二区三区,久久com

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

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

主站蜘蛛池模板: 亚洲高清在线观看 | 欧美成人二区 | 日韩视频在线免费观看 | 丁香久久 | 全免费a级毛片免费看视频免费下 | 日韩在线中文 | 午夜a√ | 国产香蕉视频在线播放 | 亚洲精品91 | 中文精品视频 | 精品一区二区三区在线观看 | 国产欧美在线 | 亚洲一区二区三区在线视频 | 日日欧美 | h免费观看 | 国产亚洲精品综合一区 | 日韩电影中文字幕 | 欧美888| 久在线视频| 精品国产乱码久久久久久a丨 | 日本不卡一区 | 亚洲国产精品一区二区第一页 | 综合国产| 欧美网站一区二区 | 毛片的网址 | 久久精品a级毛片 | 精品人伦一区二区三区蜜桃网站 | 91美女视频| 麻豆va| 成人欧美一区二区三区黑人孕妇 | 亚洲乱码一区二区三区在线观看 | 亚洲一区二区在线播放 | 国产成人精品一区二区三区在线 | 亚洲永久精品国产 | 天天操天天干天天爽 | 国产91视频一区二区 | 在线中文字幕av | 久久综合久色欧美综合狠狠 | 国产精品视频在线播放 | 久草欧美视频 | 久久久久久黄 |