2013-05-28 131 views
0

我正在嘗試使用正則表達式來查找字符串中的重複模式。我測試了我的正則表達式中的一個測試,我認爲這是我的正則表達式沒有問題,但我的代碼只返回第一個匹配(0.0000000000000000),而不是其他比賽:只匹配第一個匹配的正則表達式

這裏是我的代碼:

Dim searchstr As String 
Dim regexp As Object 
Dim colregmatch As MatchCollection 

searchstr = "ST/X 0.0000000000000000 6.4000000000000004 12.8000000000000010 19.1999999999999990 25.6000000000000010 32.0000000000000000" 
Set regexp = CreateObject("vbscript.regexp") 
With regexp 
     .Pattern = "([0-9]+\.[0-9]+)\s*" 
     .IgnoreCase = True 
     .Global = True 
     .MultiLine = True 
     .Global = False 
End With 
Set colregmatch = regexp.Execute(searchstr) 
If colregmatch.Count <> 0 Then 
     For Each Match In colregmatch 
      MsgBox Match 
     Next Match 
End If 

你能幫我解決這個問題嗎?
非常感謝

回答

2

您已將Global標誌設置爲第一個true,然後設置爲false。

.Global = True 
    .MultiLine = True 
    .Global = False 

嘗試刪除最後一個。