Skip to content

Instantly share code, notes, and snippets.

Created September 24, 2015 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/13c92dbfff3c7203353b to your computer and use it in GitHub Desktop.
Save anonymous/13c92dbfff3c7203353b to your computer and use it in GitHub Desktop.
Windows PowerShell TFM Book Contest and Giveaway
function Format-TitleCase {
<#
.SYNOPSIS
Takes a string of text in any case and formats it to the first letter in every word as capital.
.DESCRIPTION
Format-TitleCase is a function that changes a strin of test to capitalize the first letter in every word,
ignoring special characters and numbers.
.PARAMETER Words
String of text to format.
.EXAMPLE
Format-TitleCase 'StrIng oF teXT'
'StrIng oF teXT' | Format-TitleCase
.NOTES
Created John Raley
#>
[CmdletBinding()]
param (
[Parameter(Mandatory,
ValueFromPipeline)]
[String]$words
)
process {
$TextInfo = (Get-Culture).TextInfo
$TextInfo.ToTitleCase($words.ToLower())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment