February 2019
Intermediate to advanced
626 pages
15h 51m
English
The ability to capture values from a string is an incredibly useful feature of regular expressions.
When using the -match operator, groups that have been captured are loaded into the matches variable (hash table) in the order that they appear in the expression. Consider the following example:
PS> 'first second third' -match '(first) (second) (third)'TruePS> $matchesName Value ---- ----- 3 third 2 second 1 first 0 first second third
The first key, 0, is always the string that matched the entire expression. Numbered keys are added to the hash table for each of the groups in the order that they appear. This applies to nested groups as well, counting from the leftmost (:
PS> 'first second third' -match '(first) ((second) (third))' ...
Read now
Unlock full access