2013-05-22 32 views

回答

0

您可以嘗試使用http:\/\/.+\.php\?.+=.+\.php來匹配。我用於測試的一些示例可以在here找到。

它分解成你想要的不同組件,並將它們串在一起。對於匹配STRINGS,您可以使用.+進行非貪婪捕獲。這將幫助您匹配其他有效的正則表達式,如php處理。

  • http:\/\/符合您http://
  • .+\.php匹配STRING其次.php
  • \?.+=匹配?後跟一個字符串.+=
  • .+\.php終於找到了STRING隨後.php一次。

編輯:這是從myregextester.com生成VB.NET產生的一些示例代碼:

Imports System.Text.RegularExpressions 
Module Module1 
    Sub Main() 
    Dim sourcestring as String = "replace with your source string" 
    Dim re As Regex = New Regex("http:\/\/.+\.php\?.+=.+\.php") 
    Dim mc as MatchCollection = re.Matches(sourcestring) 
    Dim mIdx as Integer = 0 
    For each m as Match in mc 
     For groupIdx As Integer = 0 To m.Groups.Count - 1 
     Console.WriteLine("[{0}][{1}] = {2}", mIdx, re.GetGroupNames(groupIdx), m.Groups(groupIdx).Value) 
     Next 
     mIdx=mIdx+1 
    Next 
    End Sub 
End Module 
+0

只要我嘗試匹配,我的VB.NET就會凍結。 –

+0

@ user2230481它會拋出任何錯誤信息嗎?需要多長時間才能凍結?您使用此正則表達式的輸入有多大? – Walls

+0

不,它不會立即顯示9個字符 –

相關問題