Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Python

r"
%(?P<flags>[-+ #0]*)(?P<width>\d+|\*)?(?:\.(?P<precision>\d+|\*))?(?P<length>hh|h|l|ll|j|z|t|L|I64)?(?P<specifier>[%csdioxXufFeEaAgGnp])
"
gm

Description

Parses printf conversion specifications.

This version detects multiple flags and (space) flag. MSVC length modifier I64 is also supported.

I'm using this regex in my Python project, so please change accordingly if you use other flavor of regex.

Submitted by Haruka Ma - 4 years ago