swiss v1.4.1 Swiss.String View Source
A few extra functions to deal with Strings. Heavily inspired by lodash.
Link to this section Summary
Functions
Deburrs a string from unicode to its ascii equivalent.
Converts a string into kebab-case.
Converts a string into snake_case.
Link to this section Functions
Deburrs a string from unicode to its ascii equivalent.
Examples
iex> Swiss.String.deburr "hola señor!"
"hola senor!"
Converts a string into kebab-case.
Examples
iex> Swiss.String.kebab_case "Foo Bar"
"foo-bar"
iex> Swiss.String.kebab_case "--foo-bar--"
"foo-bar"
iex> Swiss.String.kebab_case "__FOO_BAR__"
"foo-bar"
iex> Swiss.String.kebab_case "FooBar"
"foo-bar"
Converts a string into snake_case.
Examples
iex> Swiss.String.snake_case "Foo Bar"
"foo_bar"
iex> Swiss.String.snake_case "--foo-bar--"
"foo_bar"
iex> Swiss.String.snake_case "__FOO_BAR__"
"foo_bar"
Link to this function
words(string, pattern \\ %{__struct__: Regex, opts: "", re_pattern: {:re_pattern, 0, 0, 0, <<69, 82, 67, 80, 105, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 37, 111, 0, 0, 0, 0, 0, 0, 255, 3, 254, 255, 255, 7, 254, 255, 255, 7, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 107, 120, 0, 37, 0>>}, re_version: {"8.41 2017-07-05", :little}, source: "[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+"})
View SourceDecomposes a string into an array of its words.
Examples
iex> Swiss.String.words "FredBarney"
["Fred", "Barney"]
iex> Swiss.String.words "fred, barney, & pebbles"
["fred", "barney", "pebbles"]
iex> Swiss.String.words "fred, barney, & pebbles", ~r/[^, ]+/
["fred", "barney", "&", "pebbles"]