Regular Expressions 101

Community Patterns

Bash command help flags extract

0

Regular Expression
ECMAScript (JavaScript)

/
^\s+(?:\-(?<letter>\w)\,?\s+)?(?:\-\-(?<name>\S+)(?:\[?[ =](?<value>\S+)\]?)?)?\s+(?<text>.*)$
/
gm

Description

Extracts the flag option information from a bash 'COMMAND --help'.

Submitted by anonymous - 4 years ago