> How do search word in string using javascript ~ Online tutorial

How do search word in string using javascript


How do search word in string using javascript


In program we will show How do get word from given string using java script.When you are using search keyword it is searching word in the given string if it is found then return 0 otherwise not return any value.

Program


<html>
<head>
<script type="text/javascript">
function test()
{
document.write("The given String is");
document.write("<em>"+str+"</em>");
var i=str.search(/like/);
return i;
}
</script>
</head>
<body>
<h3>
<script type="text/javascript">
var index=test("I like programming");
if(index>0)
document.write("The match is found"+"<em>"+"like"+"<em>");
else
document.write("The match is not found");
</script>
</h3>
</body>
</html>

Output

The given String is
I like programmingThe match is foundlike



Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: