Last active
June 22, 2020 00:21
-
-
Save IISResetMe/d02326d8094720c975a8c4cd03ddc7f7 to your computer and use it in GitHub Desktop.
This file contains 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
function Invoke-RegexTerror | |
{ | |
[CmdletBinding(DefaultParameterSetName = 'ToBeOrNotToBe')] | |
param( | |
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] | |
[int]$Count, | |
[Parameter(ParameterSetName = 'ToBeOrNotToBe')] | |
[switch]$Shakespeare, | |
[Parameter(ParameterSetName = 'TheLabyrinth')] | |
[switch]$Kafka | |
) | |
process { | |
$string = 'a' * $Count | |
switch($PSCmdlet.ParameterSetName){ | |
'TheLabyrinth' { | |
$string += 'lol' | |
$regex = '(a+)*$' | |
} | |
'ToBeOrNotToBe' { | |
$regex = 'a?' * $Count | |
$regex += $string | |
} | |
} | |
$Measurement = Measure-Command { | |
$string -match $regex | |
} |% TotalMilliseconds | |
[pscustomobject]@{ | |
'How long?' = "$($Measurement -as [int])ms" | |
'How Many?' = $Count | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment