View Source Hologram.Commons.StringUtils (hologram v0.2.0)
Summary
Functions
Prepends the prefix to the given string.
Prepends the prefix to the given string if the string is not empty.
Checks whether a string starts with a lowercase letter.
Wraps the given string with one string on the left side and another string on the right side.
Functions
Prepends the prefix to the given string.
Examples
iex> prepend("abc", "xyz")
"xyzabc"
Prepends the prefix to the given string if the string is not empty.
Examples
iex> prepend_if_not_empty("abc", "xyz")
"xyzabc"
iex> prepend_if_not_empty("", "xyz")
""
Checks whether a string starts with a lowercase letter.
- This function uses the
String.next_grapheme/1
function to extract the first letter of the string. - It converts the first letter to lowercase using
String.downcase/1
and compares it with the original first letter to determine if it is lowercase. - If the input string is empty, the function returns
false
.
Parameters
str
- The input string to be checked.
Returns
Returns true
if the string starts with a lowercase letter, and false
otherwise.
Examples
iex> starts_with_lowercase?("Hello")
false
iex> starts_with_lowercase?("world")
true
Wraps the given string with one string on the left side and another string on the right side.
Examples
iex> wrap("ab", "cd", "ef")
"cdabef"