我想匹配(在这个片段中)所有内容,但不包括我认为的换行符。会做。有人可以阐明我所缺少的东西吗?
Public Sub regexp()
Dim oRegExp As regexp
Dim oMatches As MatchCollection
Dim oMatch As Match
Dim sString As String
sString = _
"one" & vbNewLine & _
"two" & vbNewLine
Set oRegExp = New regexp
With oRegExp
.Global = True
.Pattern = ".+"
Set oMatches = .Execute(sString)
For Each oMatch In oMatches
Debug.Print "*" & oMatch.Value & "*"
Next oMatch
End With
End Sub
输出是
*one
*
*two
*
预期产出
*one*
*two*
如何避免输出中的换行符?谢谢。