Created
January 25, 2021 17:06
-
-
Save ndevenish/ceaf235cc9c535843b2a42b048275a5a to your computer and use it in GitHub Desktop.
regex for parsing python printf-style-formatting
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
re.compile(""" | |
% # Percent | |
(?:\((?P<mapping>[^)]*)\))? # Mapping key | |
(?P<flag>[#0\-+ ])? # Conversion Flag | |
(?P<width>\*|\d+)? # Field width | |
(?P<precision>\.(?:\*?|\d*))? # Precision | |
[hlL]? # Unused length modifier | |
(?P<format>[diouxXeEfFgGcrsa%]) # Conversion type | |
""", re.VERBOSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment