Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Golang

`
%(?P<flag>\#|\+|\-| |0)?((?P<width>[1-9])\.(?P<precision>[1-9])|(?P<widthDefaultPrecision>[1-9])|(?P<widthZeroPrecison>[1-9])\.|\.(?P<precisionDefaultWidth>[1-9]))?(?P<verb>\w{1,9})
`
gm

Description

Can be used to find all of the verbs in a golang format string. It will correctly extract verbs that would otherwise be specified by fmt.Sprintf, including their flags, width and precision.

You can test it out on the fmt documentation, here: https://golang.org/pkg/fmt/

Submitted by anonymous - 5 years ago