For different languages and platforms, pick one from here. . .
http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/
Question
I made this application that pings a hostname, but I need to grab the IP it used during the ping command and store it in a string. I have the output of the ping command stored in another string. How can I use Regex to grab the IP from the results and store it in a string?
Solution 2
For different languages and platforms, pick one from here. . .
http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/
OTHER TIPS
you can use
ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
ValidHostnameRegex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$";