Created
January 21, 2021 16:45
-
-
Save saintsGrad15/5012d20702ee4aa7d774fd842fdff715 to your computer and use it in GitHub Desktop.
A regex that validates and extracts groups from a valid HTTP "range" header
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
# Spec source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range | |
import re | |
range_header_regex = re.compile(r"^((?P<unit>[a-zA-Z]+)=)?(?P<start>\d+)?-(?P<end>\d+)?$") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment