MATCH SPECIFIC LINES IN VB.NET

ben reitman

Total Post:96

Points:676
Posted by  ben reitman
VB.Net 
 1127  View(s)
Ratings:
Rate this:

Is there a shorter way of writing this with or without regex?

Dim q1 = System.Text.RegularExpressions.Regex.Match(myString, 
       "[\n\r]finished", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
If (q1.Success) Then Exit Sub
  1. F Scott Fitzgerald

    Post:29

    Points:203
    Re: Match specific lines in VB.net

    Yes:

    Imports System.Text.RegularExpressions
    If (Regex.IsMatch(SubjectString, "(?i)\nfinished")) Then Exit Sub

    (it should be enough to check for \n unless you're also targeting old Macs (pre-OS X) files that only use \r for newlines)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!