<script language=javascript> var string="/<dphrffsdafsdaf/test/sucafss//?????///sda/122."; var string2="test/"; var string3=""; var index=string.indexOf(string2); if(index != -1) { string3=string.substring(index+5,index+7); alert(string3); } </script>