Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moriarty99779/a8bc0776cf51c7a6c5ede321ccadf408 to your computer and use it in GitHub Desktop.
Save moriarty99779/a8bc0776cf51c7a6c5ede321ccadf408 to your computer and use it in GitHub Desktop.
Javascript - Check if string is a valid IPv4 address
const checkIsValidIPv4 = (ip) => /^(?:(?: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]?)$/.test(ip);
document.write(checkIsValidIPv4("192.168.1.1"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment