下面的代码应该有2次匹配末尾,但是只有一次??为什么??
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim matchesRegex As New Regex("ef$", RegexOptions.Multiline) '正则表达式
Dim matchesFound As MatchCollection
matchesFound = matchesRegex.Matches("ab123ef" + Chr(13) & Chr(10) + "ab234ef") '搜索所有匹配
For Each match As Match In matchesFound
MsgBox(match.Value)
Next match
End Sub
^就没有问题能够正常匹配每行开头,2次
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim matchesRegex As New Regex("^ab", RegexOptions.Multiline) '正则表达式
Dim matchesFound As MatchCollection
matchesFound = matchesRegex.Matches("ab123ef" + Chr(13) & Chr(10) + "ab234ef") '搜索所有匹配
For Each match As Match In matchesFound
MsgBox(match.Value)
Next match
End Sub