最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2016年02月03日 09:26:58   作者:皮蛋  
這篇文章主要介紹了JavaScript檢查子字符串是否在字符串中的方法,涉及JavaScript查詢、正則匹配等操作技巧,需要的朋友可以參考下

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

var strnew="Hello Raghu How are u"
//Checking existence in entire string
if(strnew.indexOf("Raghu") != -1 )
{
  alert("Exists");
}
/*
Checking existence at the end of string
For 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 string
In 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");

更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript查找算法技巧總結(jié)》及《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)

希望本文所述對大家JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

健康| 定边县| 玉溪市| 白朗县| 正阳县| 中牟县| 岑巩县| 林西县| 潞西市| 吴旗县| 正安县| 庆安县| 静安区| 宜兰县| 莒南县| 汝州市| 工布江达县| 土默特右旗| 阜南县| 马公市| 沈丘县| 东明县| 包头市| 钦州市| 高州市| 尼勒克县| 乃东县| 大邑县| 比如县| 凌源市| 藁城市| 来凤县| 邹城市| 南皮县| 高密市| 化隆| 苗栗市| 台北县| 高碑店市| 城固县| 博湖县|