Skip to content

Instantly share code, notes, and snippets.

@jastisriradheshyam
Created October 29, 2018 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jastisriradheshyam/71a3801415830b3c6435bf058683afe5 to your computer and use it in GitHub Desktop.
Save jastisriradheshyam/71a3801415830b3c6435bf058683afe5 to your computer and use it in GitHub Desktop.
ipvalidation
// IPv4
var regexStringIPv4 = '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$';
var regexIPv4 = new RegExp(regexStringIPv4, flags);
console.log(regexIPv4.test("192.168.0.25.25.23")); // false
console.log(regexIPv4.test("192.168.0.25")); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment