Mega Code Archive

 
Categories / VB.Net Tutorial / Regular Expressions
 

Word count

Imports System.Text.RegularExpressions Public Class Tester     Public Shared Sub Main         Dim quote As String = _             "The important thing" & vbNewLine & _             "is not to stop questioning." & vbNewLine & _             "--Albert Einstein" & vbNewLine         Dim numWords As Integer = Regex.Matches(quote, "\w+").Count         Console.WriteLine(numWords)     End Sub End Class 10