Skip to content

Instantly share code, notes, and snippets.

@kenzauros
Created May 12, 2022 01:40
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 kenzauros/37c59d99ac3aa64b5575d731ffb9b517 to your computer and use it in GitHub Desktop.
Save kenzauros/37c59d99ac3aa64b5575d731ffb9b517 to your computer and use it in GitHub Desktop.
PowerShellでパスカルケース・ケバブケースの変換
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