Mega Code Archive

 
Categories / VB.Net Tutorial / Regular Expressions
 

Regex(w+)

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