1. String.IndexOf Method (Value[,startindex])
Value: The Unicode character to find. Required Options
StartIndex: Search start location. Option not to write from the beginning to find
The method returns an integer value,
Indicates the starting position of a substring in a string object, if no second index parameter is set, starting from subscript 0. If no substring is found, 1 is returned.
2.string.lastindexof (Char,int32)
Char: the string to find
Int32: Find within a specified range
The method returns an integer value,
Indicates the last index position of the substring of a string object, starting at subscript 0. If no substring is found, 1 is returned.
If you set the second argument, it represents the last index position within the specified range
For example:
string= "Hello Nihao a!"
String. LastIndexOf (' Nihao '); Returns 6
String. LastIndexOf (' Nihao ', 5); Returns-1
String. LastIndexOf (' Nihao ', 8); Returns 6
Finds the character within the specified range, which is the input parameter above, and is understood as the position of the last matched string, starting at index 0 to the specified numeric position range.
3.string.substring (Indexstar[,indexend])
You can write only one parameter: the string that follows the intercept from the index value
Write two parameters: A string that intercepts the start of the specified index between the end of the specified index (excluding the end index)
String= "Liming is a good boy"
String.substring (3); Back: ing is a good boy
String.substring (3,6); Return: ing that is subscript 3 start to subscript 5 end of string
The difference between JS indexOf () lastIndexOf () and substring () intercept strings