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

replace()
The replace() method retur " /> 自拍99,中文字幕一区在线播放,精品久久一区二区

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

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

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

主站蜘蛛池模板: 高粱红了 电视剧| 1998年槟榔西施| 77316电影| 爱在记忆中找你歌词| 王春晖| 坐月子吃什么| 竹内纱里奈av| 王源个人资料简介身高| 抗日电影免费| 阮虔芷个人资料| 四大名著好词好句摘抄| 鏖战鲁西南| 我和我的父辈 电影| bob hartman| 电影在线观看网址| 超越情感电视剧免费观看全集完整版| 美容室4| 音乐僵尸演员表| 看美女图片| 张韶涵个人简历| 谍变1939电视剧剧情介绍| 1024电影| kaori全部av作品大全| 大国医 电视剧| 重温经典节目预告| 触摸 电影| 疖子一般几天能熟出脓| 大场面| 金沙滩秦腔剧情介绍| 美国电影《贵夫人》| free hd xxxx moms movie777| 外出韩版| 色在线视频| 周秀娜三级大尺度视频| 山东生活频道| 太深了太爽了受不了了| 恶行之外电影完整播放| 孤战迷城电视剧剧情介绍| 免费看黄网址| 《最后的凶手》免费观看| 好好说话电视剧免费观看完整版40集|