51Testing软件测试论坛
标题:
如何匹配N个换行符?
[打印本页]
作者:
wshyzhywx
时间:
2009-11-5 11:43
标题:
如何匹配N个换行符?
正则表达式 如何匹配N个换行符?
作者:
hsjzfling
时间:
2009-11-5 12:09
换行符的表示有多种。。。举个小例子好了
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))
作者:
wshyzhywx
时间:
2009-11-5 12:15
需求不同 我现在的需求是这样的:
===start====
.........
........
....
...
===end====
我就需要检查 开头和结尾 怎么写?
"===start====(\n*)(.*)===end====" 这样为什么不行?
作者:
hsjzfling
时间:
2009-11-5 13:51
已经说了啊。。。换行符有很多种的啊,你要先确认你你要匹配的换行符是哪一种,不能确定就用 | 将3种换行符都写上,"\n"等价于vblf,多数情况下是vbcrlf
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2