Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Friday, June 26, 2009

Javascript: search for a string withing another string

//In this example i'm using regular expressions

var myRegExp = /find me/;
var string1 = "can you find me in this string?";
var matchPosition = string1.search(myRegExp);

if(matchPosition != -1){
//match was found on position matchPosition
}else{
//not found in string
}

No comments:

Post a Comment

Chitika Ads