Last active
October 4, 2022 08:36
-
-
Save SeidChr/5f0c0fd4097a52bfeea24866547f9b6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate regex match groups from arrays | |
function ContGroup { | |
param([object[]]$Source, [int]$GroupSize) | |
0..($Source.Length-$GroupSize) |% { $Source | Select -Skip $_ -First $GroupSize | Join-String } | |
} | |
# $ ContGroup -Source (1..9 + 0) -GroupSize 4 | Join-String -Separator '|' | |
# 1234|2345|3456|4567|5678|6789|7890 | |
# $ ContGroup -Source ('a'..'z') -GroupSize 3 | Join-String -Separator '|' | |
# abc|bcd|cde|def|efg|fgh|ghi|hij|ijk|jkl|klm|lmn|mno|nop|opq|pqr|qrs|rst|stu|tuv|uvw|vwx|wxy|xyz | |
# https://stackoverflow.com/q/73943221/1280354 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment