I tried this code for validating IP address, but it doesn\'t work...
public static bool IP(string ipStr)
{
string pattern = @\"^([1-9]|[1-9][0-9]|1[0-9][
Here is the complete regex for checking all possible IPv4 addresses (dotted decimal, dotted hexadecimal, dotted octal, decimal, hexadecimal, octal and mixed mode)
^(0[0-7]{10,11}|0(x|X)[0-9a-fA-F]{8}|(\b4\d{8}[0-5]\b|\b[1-3]?\d{8}\d?\b)|((2[0-5][0-5]|1\d{2}|[1-9]\d?)|(0(x|X)[0-9a-fA-F]{2})|(0[0-7]{3}))(\.((2[0-5][0-5]|1\d{2}|\d\d?)|(0(x|X)[0-9a-fA-F]{2})|(0[0-7]{3}))){3})$
I have tested it with all possible addresses.