Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2021-08-24 21:08
Flavor·PCRE2 (PHP)

/
(?(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
Open regex in editor

Description

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

Submitted by GiorgioAresu