Use LastIndexOfAny to find first occurrence of character in array : String Find « Data Type « VB.Net Tutorial






Module Tester

   Sub Main()
      Dim letters As String = "abcdefghijklmabcdefghijklm"
      Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c}

      Console.WriteLine("Last occurrence of ""c""," & _
         " ""a"" or ""$"" is located at " & _
         letters.LastIndexOfAny(searchLetters))

      Console.WriteLine("Last occurrence of ""c"", ""a"" or " & _
         """$"" is located at " & _
         letters.LastIndexOfAny(searchLetters, 1))

      Console.WriteLine("Last occurrence of ""c"", ""a"" or " & _
         """$"" is located at " & _
         letters.LastIndexOfAny(searchLetters, 25, 5))
      
      End Sub 

End Module
Last occurrence of "c", "a" or "$" is located at 15
Last occurrence of "c", "a" or "$" is located at 0
Last occurrence of "c", "a" or "$" is located at -1








2.33.String Find
2.33.1.Demonstrating StartsWith and EndsWith methods
2.33.2.Return the index of the string
2.33.3.Use IndexOf to locate a substring in a string
2.33.4.Use LastIndexOf to find a substring in a string
2.33.5.Use IndexOfAny to find first occurrence of character in array
2.33.6.Use LastIndexOfAny to find first occurrence of character in array
2.33.7.String Index of any
2.33.8.Use the LastIndexOf(Char) method to find the last directory separator character in a string
2.33.9.EndsWith method.
2.33.10.Find the index of the last occurrence of any character in the string "is" within another string.
2.33.11.IsMatch(String) determines whether a string is a valid to Regular expression