Mega Code Archive

 
Categories / VB.Net Tutorial / Regular Expressions
 

Count line

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 numLines As Integer = Regex.Matches(quote, ".+\n*").Count         Console.WriteLine(numLines)     End Sub End Class 3