I am trying to use regex for the IP address from an HTML page:
<html>
<head><title>Current IP Check</title></head>
<body>Current IP Address: xx.xxx.xxx.xx</body>
</html>
And my VB.Net code is currently this:
Using wClient As New WebClient
ip = wClient.DownloadString("http://checkip.dyndns.org/")
ip = Regex.Match(ip, "^[+-]?(\d+(\.\d+)?|\.\d+)$", RegexOptions.Singleline).ToString
End Using
However, the end results are nothing for IP.
I’m just looking to get xx.xxx.xxx.xx
What would I be doing incorrectly?
Regular expression for an IP address is much more complex than you outlined. But there is no reason to re-invent the wheel. Please have a look at Regular Expression Examples, here is the one that accounts for everything: