Created
May 12, 2022 01:40
-
-
Save kenzauros/37c59d99ac3aa64b5575d731ffb9b517 to your computer and use it in GitHub Desktop.
PowerShellでパスカルケース・ケバブケースの変換
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
function ConvertToPascalCase([Parameter(ValueFromPipeline)] [string] $text) { | |
($text -split '-' | ForEach-Object { | |
"$($_.ToCharArray()[0].ToString().ToUpper())$($_.Substring(1))" }) -join '' | |
} | |
function ConvertToKebabCase([Parameter(ValueFromPipeline)] [string] $text) { | |
([regex]"^-*").Replace(([regex]"[A-Z]").Replace($text, { "-" + $args[0].Groups[0].Value.ToLower() }), "") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment