Skip to content

Instantly share code, notes, and snippets.

@ryanspletzer
Last active February 2, 2018 01:00
Show Gist options
  • Save ryanspletzer/08c4dcb7126f55f93ac04cbc5520fd01 to your computer and use it in GitHub Desktop.
Save ryanspletzer/08c4dcb7126f55f93ac04cbc5520fd01 to your computer and use it in GitHub Desktop.
ConvertTo-TheLettersAndNumbers.ps1
function ConvertTo-TheLettersAndNumbers {
[CmdletBinding()]
[OutputType([string])]
param (
[Parameter(Mandatory=$true)]
[string]
$String
)
$numbers = @{
0 = ':zero:'
1 = ':one:'
2 = ':two:'
3 = ':three:'
4 = ':four:'
5 = ':five:'
6 = ':six:'
7 = ':seven:'
8 = ':eight:'
9 = ':nine:'
}
$String = ($String -replace '([a-zA-Z])',':the_$1:').ToLower()
foreach ($number in $numbers.Keys) {
$String = $String.Replace($number, $numbers[$number]))
}
Write-Output -InputObject $String
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment