String.replace_trailing
You're seeing just the function
replace_trailing
, go back to String module for more information.
Specs
Replaces all trailing occurrences of match
by replacement
in string
.
Returns the string untouched if there are no occurrences.
If match
is ""
, this function raises an ArgumentError
exception: this
happens because this function replaces all the occurrences of match
at
the end of string
, and it's impossible to replace "multiple" occurrences of
""
.
Examples
iex> String.replace_trailing("hello world", " world", "")
"hello"
iex> String.replace_trailing("hello world world", " world", "")
"hello"
iex> String.replace_trailing("hello world", " world", " mundo")
"hello mundo"
iex> String.replace_trailing("hello world world", " world", " mundo")
"hello mundo mundo"