Use indexOf method the search a substring
|
|
<html> <head> <title>Using the indexOf() method</title> <script type="text/javascript" language="javascript"> <!-- //
var myString = "A ab abc abcd"; var mySubstring = "abc"; var foundAtPosition; foundAtPosition = myString.indexOf(mySubstring,0);
document.write("<P>The string " + mySubstring + " was found at position " + foundAtPosition); // --> </script> </head> <body>
</body> </html>
|
|
|
HTML code for linking to this page:
Related in same category :
-
-
|