The usage of substr,substring,indexof,lastindexof in JS
1.substr
SUBSTR (start,length) indicates that the length of a string is intercepted from the start position.
var src= "Images/off_1.png";
Alert (SRC.SUBSTR (7,3));
The pop-up value is: off
2.substring
SUBSTRING (start,end) represents a string from start to end, including characters from the start position but not the end position.
var src= "Images/off_1.png";
Alert (src.substring (7,10));
The pop-up value is: off
3.indexOF
The IndexOf () method returns the first occurrence of a specified string value in a string, from left to right. If no match is returned-1, otherwise returns the subscript value of the string for the first occurrence of the position.
var src= "Images/off_1.png";
Alert (Src.indexof (' t '));
Alert (Src.indexof (' I '));
Alert (Src.indexof (' G '));
The pop-up values are: -1,0,3
4.lastIndexOf
The LastIndexOf () method returns the first character index value (contrary to indexof) of a character or string appearing from right to left, noting that the index is still computed from left to right
var src= "Images/off_1.png";
Alert (Src.lastindexof ('/'));
Alert (Src.lastindexof (' G '));
The pop-up values, in turn, are: 6,15