There are multiple errors:
First, you are using it wrong: When using regexInstance.Match(), the second parameter is the start-offset - not the Regex Options.
To use Regex Options, use the Static Version of Match()
along with a String Pattern:
Dim regexStr As String = "<table class=""listing"">.*?</table>"
Dim match As Match = Regex.Match(Str, regexStr, RegexOptions.IgnoreCase Or RegexOptions.Singleline)
or add the options to the constructor:
Dim regex As Regex = New Regex("<table class=""listing"">.*?</table>", RegexOptions.IgnoreCase Or RegexOptions.Singleline)
Dim match As Match = regex.Match(str)
Second, you need to Provide RegexOptions.SingleLine
additional to IgnoreCase
.
(So: RegexOptions.IgnoreCase Or RegexOptions.SingleLine
)
The HTML String contains Linebreaks, which your Regex simple doesn't match.
In Single-Line Mode the .
will also match New Lines https://msdn.microsoft.com/en-us/library/yd1hzczs%28v=vs.110%29.aspx#Singleline
putting all together:
Dim Str As String = "<table class=""listing"">" & System.Environment.NewLine & "test" & System.Environment.NewLine & "</table>"
Dim regexStr As String = "<table class=""listing"">.*?</table>"
Dim match As Match = Regex.Match(Str, regexStr, RegexOptions.IgnoreCase Or RegexOptions.Singleline)
If match.Success Then
MsgBox(match.Value)
End If