Use indexOf method the search a substring : indexOf « String « JavaScript Tutorial






<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>








6.16.indexOf
6.16.1.String.indexOf()
6.16.2.Get a substring index
6.16.3.Use indexOf method the search a substring