Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(?(DEFINE)(?'value'(?:\N*(?:\n(?:(?: {8}|\t)\N*))*)))\s*pool: (?'pool'\g'value')\n\s*state: (?'state'\g'value')\n((?:\s*status: (?'status'\g'value')\n)?(?:\s*action: (?'action'\g'value')\n)?\s*scan: (?'scan'\g'value')\n)?\s*config:\n\n(?'config'\g'value')\n\s*errors: (?'errors'\g'value')
/
s

Description

Matches the output of zpool status -v. Use preg_match_all with PREG_SET_ORDER to match multiple pools

Submitted by GiorgioAresu - 3 years ago