Created
May 29, 2024 22:17
-
-
Save moriarty99779/a8bc0776cf51c7a6c5ede321ccadf408 to your computer and use it in GitHub Desktop.
Javascript - Check if string is a valid IPv4 address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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