匹配特定的行

时间:2013-10-05 08:07:27

标签: regex vb.net

使用或不使用正则表达式,是否有更短的写入方式?

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

1 个答案:

答案 0 :(得分:2)

是:

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

(检查\n应该足够了,除非您还定位仅使用\r替换新行的旧Mac(OS X前)文件)