View Source Recase.Generic (recase v0.8.1)

Generic module to split and join strings back or convert strings to atoms. This module should not be used directly.

Summary

Functions

Splits the input and rejoins it with a separator given. Optionally converts parts to downcase, upcase or titlecase.

Atomizes a string value. Uses an existing atom if possible.

Splits the input into list. Utility function.

Functions

Link to this function

rejoin(input, opts \\ [])

View Source
@spec rejoin(input :: String.t(), opts :: Keyword.t()) :: String.t()

Splits the input and rejoins it with a separator given. Optionally converts parts to downcase, upcase or titlecase.

  • opts[:case] :: [:down | :up | :title | :none]

  • opts[:separator] :: binary() | integer() Default separator is ?_, default conversion is :downcase so that it behaves the same way as to_snake/1.

Examples

iex> Recase.Generic.rejoin "foo_barBaz-λambdaΛambda-привет-Мир", separator: "__"
"foo__bar__baz__λambda__λambda__привет__мир"
@spec safe_atom(String.t()) :: atom()

Atomizes a string value. Uses an existing atom if possible.

@spec split(input :: String.t()) :: [String.t()]

Splits the input into list. Utility function.

Examples

iex> Recase.Generic.split "foo_barBaz-λambdaΛambda-привет-Мир"
["foo", "bar", "Baz", "λambda", "Λambda", "привет", "Мир"]