Created
January 25, 2019 15:24
-
-
Save ovarunendra/e1ee4cf451e99267fb4eb7de1ea86e5e to your computer and use it in GitHub Desktop.
MAC-IP-PORT JS Regex
This file contains hidden or 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 MAC_REGEX = '^[a-zA-Z0-9]{12}$'; | |
const IP_REGEX = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}'; | |
const PORT_REGEX = '(?::+(\\d{2,4}))?'; | |
const IP_PORT_REGEX = `(${IP_REGEX})${PORT_REGEX}`; | |
const MAC_IP_PORT_REGEX = `(^${MAC_REGEX}$)|(^${IP_PORT_REGEX}$)`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment