如何匹配N个换行符?
正则表达式 如何匹配N个换行符? 换行符的表示有多种。。。举个小例子好了Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & "Match " & I & " found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is "'
RetStr = RetStr & Match.Value & "'." & VbCrLf
Next
RegExpTest = RetStr
End Function
s = "1"&vbNewLine&"2"&VbCrLf&"3"&vbCr&"4"&vbLf&"5"
MsgBox(RegExpTest(vbLf&"+", s)) 需求不同我现在的需求是这样的:
===start====
.........
........
....
...
===end====
我就需要检查 开头和结尾 怎么写?
"===start====(\n*)(.*)===end===="这样为什么不行? 已经说了啊。。。换行符有很多种的啊,你要先确认你你要匹配的换行符是哪一种,不能确定就用 | 将3种换行符都写上,"\n"等价于vblf,多数情况下是vbcrlf
页:
[1]