This RegEx can be used to check whether a string (usually a commit message) matches the structure specified in the conventional commits specification and it allows to retrieve the sections of the structure via. named groups.
The groups are the following:
(?
means, that this can be empty/nullable)
type
- The commit type (e.g. feat
, fix
, etc.)scope
? - The optional scope of the commit (e.g. the part of the codebase that the changes affect)breaking
? - !
or empty - whether breaking changes where marked using an exclamation mark after the type/scopedescription
- The (short) one-line description of the commitbody
? - The optional (multiline) long description of the commitfooters
? - The optional footer(s) of the commitIf you have any questions or found something that is wrong take a look on my GitHub for contact details