Imports System.Text.RegularExpressions
Public Class Tester
Public Shared Sub Main
Dim quote As String = "q d e w "
Do While (quote.IndexOf(Space(2)) >= 0)
quote = quote.Replace(Space(2), Space(1))
Loop
Dim wordCount As Integer = Split(quote, Space(1)).Length
Console.WriteLine(quote & vbNewLine & "Number of words: " & wordCount.ToString)
End Sub
End Class
|