国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JavaScript檢查子字符串是否在字符串中的方法

2019-11-20 10:37:32
字體:
來源:轉載
供稿:網友

本文實例講述了JavaScript檢查子字符串是否在字符串中的方法。分享給大家供大家參考,具體如下:

var strnew="Hello Raghu How are u"http://Checking existence in entire stringif(strnew.indexOf("Raghu") != -1 ){  alert("Exists");}/*Checking existence at the end of stringFor example, variable result1 in the following example is assigned the value of true because the word "Ishmael" appears at the end of the string. Variable result2 is assigned a value of false because "Raghu" doesn't appear at the end of the string.*/result1 = /Raghu$/.test("Call me Raghu");result2 = /Raghu$/.test("Call me Raghu. Some years ago");/*Checking existence in the begining of stringIn the following example, variable result1 is assigned the value of true because the word "Birds" appears at the beginning of the string. Variable result2 is assigned the value of false because "Birds" doesn't appear at the beginning of the string.*/result1 = /^Birds/.test("Birds fly");result2 = /^Birds/.test("Big Birds fly");

更多關于JavaScript相關內容感興趣的讀者可查看本站專題:《JavaScript查找算法技巧總結》及《JavaScript數據結構與算法技巧總結

希望本文所述對大家JavaScript程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临夏县| 七台河市| 肥东县| 汤原县| 碌曲县| 赤壁市| 荔浦县| 文化| 乌拉特后旗| 竹溪县| 临高县| 泽库县| 乐山市| 盐津县| 桂平市| 临江市| 垫江县| 南平市| 同江市| 道孚县| 乌兰察布市| 淳化县| 漳平市| 云阳县| 东乡族自治县| 红安县| 汤阴县| 栾川县| 金堂县| 古蔺县| 新乡县| 五寨县| 红河县| 宁明县| 西和县| 房山区| 滦平县| 项城市| 甘洛县| 海丰县| 诸城市|