Imports System.Text.RegularExpressions
Public Class Tester
Public Shared Sub Main
Dim quote As String = "AA BB in"
Dim count1 As Integer
Dim count2 As Integer
Dim count3 As Integer
count1 = Regex.Matches(quote, "(in)+").Count
count2 = Split(quote, "in").Length - 1
Dim content As String = "in"
Dim position As Integer = -content.Length
Do
position = quote.IndexOf(content, position + content.Length)
If (position < 0) Then Exit Do
count3 += 1
Loop
Console.WriteLine(String.Format( _
"{0}{3}{1}{3}{2}", count1, count2, count3, vbNewLine))
End Sub
End Class
1
1