This article is mainly on the use of JS indexof in a detailed introduction, the need for friends can come to the reference, I hope to help you.
The String.IndexOf method (Char, [StartIndex], [count]) reports the index of the first occurrence of the specified character in this instance. The search starts at the specified character position and checks the specified number of character positions. Parameters value Unicode characters to find. Searches for value are case-sensitive. StartIndex (Int32) Optional, search starting position. is not set to start at 0. COUNT (Int32) optional, number of character positions to check. Return value If the character is found, the index position of value, or 1 if not found. IndexOf () Find the location of the first occurrence of a specified character or string in a string, and return to the first index value, such as: STR1. IndexOf ("word");//Find the index value (position) STR1 of the word in str1. IndexOf ("string");//Find the index value (position) STR1 of the first character of the string in str1. IndexOf ("word", start,end)//from str1 start+1 characters, find the end character, find the position of "word" in the string STR1 [from the first character] Note: Start+end cannot be greater than the length of str1 The indexof parameter is string, looking for the first occurrence of the parameter string in the string and returning the position. such as String s= "0123DFDFDF"; int i=s.indexof ("df"); then i==4. If you need more powerful string parsing functionality, you should use the Regex class to match strings using regular expressions. indexof (): Locates characters and strings in a string from the back; all return values are in absolute position of the string, such as null 1 string test= "asdfjsdfjgkfasdsfsgfhgjgfjgdddd" ; Test.indexof (' d ') = 2//front-and-back position D first occurrence test.indexof (' d ', 1) = 2//front-backward positioning D from the third string first occurrence of the position Test.ind Exof (' d ', 5,2) =6 Pre-position D from the 5th to check, check 2 digits, that is, from 5th to 7th; LastIndexOf (): Position characters and strings from behind in a string; usage and indexof () are identical. below introduce IndexOfAny | | Lastindexofany They accept the character array as the variable, the other methods above, return the first occurrence of any character in the array subscript position as follows char[] bbv={' s ', ' C ', ' B '}; String abc = "Acsdfgdfgchacscdsad"; Response.Write (ABC. IndexOfAny (BBV)) =1 Response.Write (ABC. IndexOfAny (BBV, 5)) =9 Response.Write (ABC. IndexOfAny (BBV, 5, 3)) =9 Lastindexofany Ibid.