/
SpOnGeBoB
31 lines (27 loc) · 983 Bytes
/
SpOnGeBoB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Spongebob ([string]$String,[switch]$Reverse,[switch]$Random,[switch]$Both)
{
# Array for output
$Result = @()
# Spongebobify input
foreach ($Char in ($String.ToCharArray()))
{
switch (($Special = ($Char -match "[\W\s]")),($Count = ((Get-Random (0,1)) % 2 -eq 0)))
{
{($Special-eq $FALSE) -and ($Count -eq $TRUE)} {$Result += $Char.ToString().ToUpper(); BREAK}
{($Special-eq $FALSE) -and ($Count -eq $FALSE)} {$Result += $Char.ToString().ToLower(); BREAK}
{($Special-eq $TRUE)} {$Result += $Char; BREAK}
}
}
# Reverse character order if Reverse flag is used
if ($Reverse -or $Both)
{
[array]::Reverse($Result)
}
# Randomize word order if Random flag is used
if ($Random -or $Both)
{
$Result = (($Result -join "") -split " " | Sort-Object {Get-Random}) -join " "
}
# Copy result to clipboard
Set-Clipboard ($Result -join "")
}