国产探花免费观看_亚洲丰满少妇自慰呻吟_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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 怀集县| 浦县| 灯塔市| 灵台县| 阳泉市| 黔江区| 鸡泽县| 济宁市| 石渠县| 凤冈县| 土默特左旗| 新乡市| 珲春市| 阜城县| 大化| 仁化县| 顺义区| 娄底市| 海阳市| 论坛| 万源市| 巍山| 扎鲁特旗| 崇左市| 荣成市| 巴马| 蕲春县| 灵山县| 寻乌县| 吉安县| 常宁市| 永新县| 青海省| 绵竹市| 山东省| 彰化市| 勃利县| 买车| 衡水市| 巴林左旗| 和硕县|