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

replace()
The replace() method retur " /> 欧美人与性禽xxxx,亚洲欧美日韩中文综合在线不卡,久国产视频

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

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

主站蜘蛛池模板: 深夜福利一区 | 涩涩网址| 精品阁 | 激情五月开心婷婷 | 欧美日韩亚洲成人 | 国产91中文 | 91亚洲国产系列精品第56页 | 91嫩草国产在线观看免费 | 美女张腿男人桶免费视频 | 免费91视频 | 在线免费观看色视频 | 亚洲成人中文 | 欧美日韩一区二区三 | 欧美国产一区二区二区 | 久久久久国产一级毛片高清片 | 综合图片亚洲网友自拍10p | 好吊妞视频这里有精品 | 精品中文字幕久久久久久 | 日本久久综合 | 一级特黄国产高清毛片97看片 | 四虎影视免费永久在线观看黄 | 51国产黑色丝袜高跟鞋 | 国产在线麻豆自在拍91精品 | 国产xh98hx在线观看 | 人人公开免费超级碰碰碰视频 | 免费福利视频网址 | 美女黄的全免费 | 亚洲成a人片毛片在线 | 免费永久在线观看污污的网站 | 国产精品一区91 | 人人做天天爱夜夜爽中字 | 国产精品分类视频分类一区 | 2019天天干天天操 | 色婷婷.com| 国产三级网站在线观看 | 真人午夜a一级毛片 | 亚洲综合激情另类小说区 | 国内精品久久久久久久亚洲 | 日本视频www | 亚洲乱码在线视频 | 国产精品 第1页 |