Skip to content
Snippets Groups Projects
Commit 8ee1d17c authored by Moul's avatar Moul
Browse files

[enh] #170: Define more compact ipv4 regex

composed out of common part
parent 870ce715
No related branches found
No related tags found
2 merge requests!157v1.0.0rc0: merge dev into master,!145#170: Endpoints' regex improvement
...@@ -28,10 +28,9 @@ CONDITIONS_REGEX = ( ...@@ -28,10 +28,9 @@ CONDITIONS_REGEX = (
pubkey_regex=PUBKEY_REGEX, hash_regex=HASH_REGEX pubkey_regex=PUBKEY_REGEX, hash_regex=HASH_REGEX
) )
) )
IPV4_REGEX = ( # https://stackoverflow.com/a/17871737
"(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][" IPV4SEG = "(?:25[0-5]|(?:2[0-4]|1?\\d)?\\d)"
"0-9]|25[0-5])" IPV4_REGEX = f"(?:{IPV4SEG}\\.){{3}}{IPV4SEG}"
)
IPV6_REGEX = ( IPV6_REGEX = (
"(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[" "(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2["
"0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1," "0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment