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
0 comments:
Post a Comment