Hello I am using indexOf method to search if a string is present inside another string. But I want to get all the locations of where string is? Is there any method to get all the locations where the string exists?
<html>
<head>
<script type="text/javascript">
function clik()
{
var x='hit';
//document.getElementById('hideme').value ='';
document.getElementById('hideme').value += x;
alert(document.getElementById('hideme').value);
}
function getIndex()
{
var z =document.getElementById('hideme').value;
alert(z.indexOf('hit'));
}
</script>
</head>
<body>
<input type='hidden' id='hideme' value=""/>
<input type='button' id='butt1' value="click click" onClick="clik()"/>
<input type='button' id='butt2' value="clck clck" onClick="getIndex()"/>
</body>
</html>
Is there a method to get all positions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…