Javascript - How to Search a word in a given string?

by barkkathulla 2014-06-18 18:47:33

var bulk_string=$('.content_class_name').val();
var given_word = 'myfavourate';
var regex = new RegExp( '\b' + given_word + '\b' );
var result = regex.test(bulk_string);

if(result==true)
{
	alert("Word exists in given string");
	return false;
}
1231
like
0
dislike
0
mail
flag

You must LOGIN to add comments