Skip to content

Instantly share code, notes, and snippets.

@Crinfarr
Created October 31, 2025 20:38
Show Gist options
  • Select an option

  • Save Crinfarr/0f6758d7365c68785ee2824ba02fbc78 to your computer and use it in GitHub Desktop.

Select an option

Save Crinfarr/0f6758d7365c68785ee2824ba02fbc78 to your computer and use it in GitHub Desktop.
Regex that matches (EXACTLY!) any valid IPv4
(((2((5[0-5])|[0-4][0-9]))|(1[0-9][0-9])|([1-9][0-9])|([1-9]))\.)(((2((5[0-5])|[0-4][0-9]))|(1[0-9][0-9])|([1-9][0-9])|([0-9]))\.){2}((2((5[0-5])|[0-4][0-9]))|(1[0-9][0-9])|([1-9][0-9])|([1-9]))
(((2((5[0-5])|[0-4]\d))|(1\d\d)|([1-9]\d)|([1-9]))\.)(((2((5[0-5])|[0-4]\d))|(1\d\d)|([1-9]\d)|(\d))\.){2}((2((5[0-5])|[0-4]\d))|(1\d\d)|([1-9]\d)|([1-9]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment