View Source Transmogrify.Pascalcase (transmogrify v1.1.0)

Convert strings to PascalCase

Link to this section Summary

Functions

Convert a string to camelCase, usually when originally snake_case, using the following rules

Link to this section Functions

@spec convert(String.t()) :: String.t()

Convert a string to camelCase, usually when originally snake_case, using the following rules:

  • first letter is always capitalized
  • ascii alphabetic letters immediately following an underscore are capitalized
  • underscores are removed
  • existing case and other characters are preserved in all other cases
iex> convert("PASCALCASE")
"PASCALCASE"
iex> convert("_pascal___case__")
"PascalCase"
iex> convert("pascal_case")
"PascalCase"
iex> convert("pascal_case")
"PascalCase"
iex> convert("PascalCASE")
"PascalCASE"
iex> convert("Pascal_CASE")
"PascalCASE"
iex> convert("PascalCase")
"PascalCase"
iex> convert("pascal_9case")
"Pascal9case"