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][
I'm not really a regex expert per se but i use Expresso (a regex tool) and it has it's own regex library for pre-set scenarios like this. Try this below.
string pattern = @"(?2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?2[0-4]\d|25[0-5]|[01]?\d\d?)";