forked from dfinke/Tiny-PowerShell-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfriar.ps1
45 lines (35 loc) · 1.02 KB
/
friar.ps1
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<#
Author: Doug Finke
Email: [email protected]
Blog: https://dfinke.github.io/
Twitter: https://twitter.com/dfinke
GitHub: https://github.com/dfinke
YouTube: https://www.youtube.com/dougfinke
PowerShell Meetup: https://www.meetup.com/NycPowershellMeetup/
LinkedIn: https://www.linkedin.com/in/douglasfinke/
#>
param(
$text
)
function Invoke-Fry {
param($word)
if ($word.ToLower() -eq 'you') {
$word[0] + "'all"
}
if ($word.EndsWith('ing')) {
if ($word.Substring(0, ($word.Length - 3)).IndexOfAny('AaEeIiOoUuYy'.ToCharArray()) -gt -1) {
$word.Substring(0, ($word.Length - 1)) + "'"
}
else {
$word
}
}
}
if (Test-Path $text -ErrorAction SilentlyContinue) {
$text = Get-Content $text
}
$(foreach ($line in $text.Split("`n")) {
foreach ($word in [regex]::Split($line.Trim(), '\W+')) {
Invoke-Fry $word
}
}) -join ' '