JS in the use of substr,substring,indexof,lastindexof, etc.
1.substr
SUBSTR (Start,length) is a string that starts at the start position and intercepts length lengths.
var src= "Images/off_1.png";
Alert (SRC.SUBSTR (7,3));
The popup value is: Off
2.substring
SUBSTRING (start,end) represents a string from start to end, including the character of the start position but not the end position.
var src= "Images/off_1.png";
Alert (src.substring (7,10));
The popup value is: Off
3.indexOF
The IndexOf () method returns the position (left-to-right) of the first occurrence of a specified string value in a string. Returns 1 if there is no match, otherwise returns the subscript value of the string where the first occurrence occurs.
var src= "Images/off_1.png";
Alert (Src.indexof (' t '));
Alert (Src.indexof (' I '));
Alert (Src.indexof (' G '));
The popup value is: -1,0,3
4.lastIndexOf
The LastIndexOf () method returns the first character index value of a character or string that appears right-to-left (as opposed to indexof)
var src= "Images/off_1.png";
Alert (Src.lastindexof ('/'));
Alert (Src.lastindexof (' G '));
The popup values are: 6,15
5.filename.size ()-filename.lastindexof ('/')-1
For example, if the path is d:/my documents/tcp/header.h
Filename.lastindexof ('/') returns the number of digits from Start D to the last
Filename.right (8) means a string that starts from the right of the path to the eighth digit.
QString Currentfile=filename.right (Filename.size ()-filename.lastindexof ('/')-1);
The above can be combined with this article http://www.cnblogs.com/zcttxs/archive/2012/05/21/2511947.html see, more clearly.
filename, extension intercept what you have to know.