Language = Visual Basic. I have a project that use .Net framework 4
I have this code for Regex:
Private Shared RegPattern As New Regex("\<base+.+?href\s*\=\s*(""(?<HREF>[^""]*)""|'(?<HREF>[^']*)')(\s*\w*\s*\=\s*(""[^""]*""|'[^']*')|[^>])*(\/>|>\<\/base\>)", RegexOptions.IgnoreCase Or RegexOptions.Singleline)
I have this function to get links from a html page:
Private Sub GetAdress(ByVal HtmlPage As String)
Base = ""
Dim Matches As System.Text.RegularExpressions.MatchCollection = RegPattern.Matches(HtmlPage)
For Each V_Found As System.Text.RegularExpressions.Match In Matches
Base = V_Found.Groups("HREF").Value
End Sub
The function works fine but in some cases enter in a infinite loop. The debugger says "Evaluation Time out" at the line:
Dim Matches As System.Text.RegularExpressions.MatchCollection = RegPattern.Matches(HtmlPage)
and the exe not continue or exit or catch exceptions. How can i handle this problem? How can i exit from GetAddress method? I know there is timeoutexception but in net 4 i can't use it.