Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,929 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
My code is below
Dim a As String = "ABCD efabCd efcdfg"
Dim b As String = "cd"
Dim i As Int32 = a.IndexOf(b, StringComparison.OrdinalIgnoreCase)
There are 3 "cd" in the a string, how to return all index locations? I need to return "2, 9, 14", but the i only return "2".
Dim a As String = "ABCD efabCd efcdfg"
Dim b As String = "cd"
Dim rx = New Regex(b, RegexOptions.Compiled Or RegexOptions.IgnoreCase)
Dim match As Match = rx.Match(a)
Do While match.Success
MessageBox.Show(match.Value & ": " & match.Index)
match = match.NextMatch()
Loop