Created
July 25, 2017 20:57
-
-
Save rautamiekka/e6e088f085a553778992dfd9e1ffb2da to your computer and use it in GitHub Desktop.
IPv4 universal complete RegEx with options
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
NOTE: Each RegEx is a single line and Java users, for example, need to mind Java's additional requirements (such as escaping escape characters), otherwise they should work in every RegEx flavor. | |
This code ain't my work originally, I modified it. | |
------------------------------------------------------------------------- | |
No support to get the individual sections: | |
``` | |
(?:[1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(?:[1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(?:[1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.(?:[1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) | |
``` | |
With support to get each section with match groups 1-4 | |
``` | |
([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment