Last active
February 16, 2021 22:15
-
-
Save gsscoder/448eb44002e09b115a89f4e5bb19dbd1 to your computer and use it in GitHub Desktop.
PowerShell function to convert kebab-case to PascalCase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# '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