View Source Stringly (stringly v0.1.0)
Stringly is a wide variety of string manipulation functions.
Summary
Functions
Limits the number of strings.
Returns everything after the given value in a string.
Generates a URL friendly slug from the given string.
Limits the number of words in a given string.
Functions
@spec limit(String.t(), pos_integer(), String.t()) :: String.t()
Limits the number of strings.
If the number of strings exceeds the specified limit, this function will truncate the string and appends a truncation string.
Examples
iex> Stringly.limit("Hello world")
"Hello world"
iex> Stringly.limit("Hello world", 5)
"Hello..."
iex> Stringly.limit("Hello world", 5, ">>>")
"Hello>>>"
Returns everything after the given value in a string.
The entire string will be returned if the value does not exist within the string.
Examples
iex> Stringly.remainder_after("Elixir is functional programming language", "is functional")
"programming language"
iex> Stringly.remainder_after("Elixir is functional programming language")
"Elixir is functional programming language"
Link to this function
slug(title, case_option \\ :default, separator \\ "-", language \\ "en", dictionary \\ %{"@" => "at"})
View SourceGenerates a URL friendly slug from the given string.
Examples
iex> Stringly.slug("Post #1: Is Elixir A Functional Programming Language?")
"Post-1-Is-Elixir-A-Functional-Programming-Language"
iex> Stringly.slug("Post #1: Is Elixir A Functional Programming Language?", :downcase)
"post-1-is-elixir-a-functional-programming-language"
iex> Stringly.slug("Post #1: Is Elixir A Functional Programming Language?", :upcase)
"POST-1-IS-ELIXIR-A-FUNCTIONAL-PROGRAMMING-LANGUAGE"
@spec words(String.t(), pos_integer(), String.t()) :: String.t()
Limits the number of words in a given string.
If the number of words exceeds the specified limit, the function truncates the words and appends a truncation string.
Examples
iex> Stringly.words("Elixir is a functional programming language")
"Elixir is a functional programming language"
iex> Stringly.words("Elixir is a functional programming language", 5)
"Elixir is a functional programming..."
iex> Stringly.words("Elixir is a functional programming language", 5, ">>>")
"Elixir is a functional programming>>>"