Home > DeveloperSection > Forums > Match specific lines in VB.net
ben reitman
ben reitman

Total Post:96

Points:676
Posted on    October-05-2013 2:46 AM

 VB.Net VB.Net 
Ratings:


 1 Reply(s)
 847  View(s)
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


F Scott Fitzgerald
F Scott Fitzgerald

Total Post:29

Points:203
Posted on    October-05-2013 4:23 AM

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)


Don't want to miss updates? Please click the below button!

Follow MindStick