2013-05-22 33 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个字符 –

相关问题