Some times we required to validate IP address of system through Regex, then this example is the solution for your requirement, See the example:
- public bool IsValidateIP(string Address)
- {
-
- string Pattern = @"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";
-
- Regex check = new Regex(Pattern);
-
-
- if (string.IsNullOrEmpty(Address))
-
- return false;
- else
-
- return check.IsMatch(Address, 0);
- }
Above function is validating IP address is provided. just need to remember the pattern which takes measure role for validating IP address.