Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Last active February 16, 2021 22:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsscoder/448eb44002e09b115a89f4e5bb19dbd1 to your computer and use it in GitHub Desktop.
Save gsscoder/448eb44002e09b115a89f4e5bb19dbd1 to your computer and use it in GitHub Desktop.
PowerShell function to convert kebab-case to PascalCase
# 'hello-wonderful-world' | ConvertTo-PascalCase
# outcome: HelloWonderfulWorld
function ConvertTo-PascalCase([Parameter(ValueFromPipeline)] [string] $text) {
($text -split '-' | ForEach-Object {
"$($_.ToCharArray()[0].ToString().ToUpper())$($_.Substring(1))" }) -join ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment