diff --git a/Pwsh/Regex/Match-Captures-Groups-Collections.ps1 b/Pwsh/Regex/Match-Captures-Groups-Collections.ps1 new file mode 100644 index 0000000..eb2dff8 --- /dev/null +++ b/Pwsh/Regex/Match-Captures-Groups-Collections.ps1 @@ -0,0 +1,22 @@ + +$single = [regex]::Matches('a9', '9') + +$few = [regex]::Matches('sda324r32 d23 ew', '(?.+)') +$few.Captures.Groups | Ft +$few.Groups | Ft + +$single[0].Groups | Ft ; hr ; +$single[0].Captures.groups | Ft + hr -fg magenta +$few[0].Groups | Ft ; hr ; +$few[0].Captures.groups | Ft + +$single | %{ $_.Captures[0].Groups[0].gettype() } # -is +$single | %{ $_.Captures[0].Groups[999].gettype() } # -is +$single | %{ $_.Captures[0].Groups.count } # but the length is 1 + +$few | %{ $_.Captures[0].Groups[0].gettype() } # -is +$few | %{ $_.Captures[0].Groups[999].gettype() } # -is +$few | %{ $_.Captures[0].Groups.count } # but the length is 2 + +$few | %{ $Null -eq $_.Captures[1] } # Is always true null for >= 1