DarkMatter.Strings (DarkMatter v1.1.4) View Source
General utils for working with strings.
Link to this section Summary
Functions
Determine if a string is blank.
Determine if a string is blank.
Capitalizes all words in the given binary
that are separated by the given separator
Concats a list of strings. Similar to CONCAT_WS
in postgres.
Normalize a binary.
Strip non-alphanumeric chars from binary
Removes non word characters.
Removes whitespace chars.
Link to this section Functions
Specs
Determine if a string is blank.
Examples
iex> blank?(nil)
true
iex> blank?("")
true
iex> blank?(" ")
false
iex> blank?("a dog ran down the street")
false
Specs
Determine if a string is blank.
Examples
iex> blank?(" ", trim: true)
true
iex> blank?(" ", %{trim: true})
true
Specs
Capitalizes all words in the given binary
that are separated by the given separator
Examples
iex> capitalize_words("a dog ran down the street")
"A Dog Ran Down The Street"
Specs
Concats a list of strings. Similar to CONCAT_WS
in postgres.
Examples
iex> concat_ws(["", nil, %{}, "first", "time"])
"first time"
Specs
Normalize a binary.
Examples
iex> normalize("a dog ran down the street")
"a dog ran down the street"
Specs
Strip non-alphanumeric chars from binary
Examples
iex> strip_non_digit("a dog ran down the street")
""
iex> strip_non_digit("123-456#1526")
"1234561526"
Specs
Removes non word characters.
Examples
iex> strip_non_words_characters("a dog ran down the street")
"adograndownthestreet"
Specs
Removes whitespace chars.
Examples
iex> strip_whitespace("a dog ran down the street")
"adograndownthestreet"