Method 1:
Public static int indexOf (string/character, int starts from the nth digit, int queries several digits)
String tests = "1absjjkcbfka2rsbcfak2bfka1"; // test string
Int I = tests. IndexOf ("2b", 5, tests. Length-5); // search for "2b" from the fifth character"
TextBox2.Text = I. ToString ();
Int I = tests. IndexOf ("2b", 5, 2); // you can check whether two characters (2b) exist after the fifth character"
-1 indicates "2b" is not found"
LastIndexOf
Int g = tests. lastIndexOf ("2b", 5, tests. length-5); // indicates to search for "2b" from left to right of a sequential string, and return the position of the last "2b" in the string.
// Obtain the number of special strings in a string
String [] j = tests. Split ('A ');
TextBox1.Text = j. Length. ToString ();
Method 2:
TextBox2.Text = Regex. Matches (tests, "a"). Count. ToString (); // obtain the number of "a" in tests