View Source z_string (zotonic_stdlib v1.17.0)
Link to this section Summary
Functions
Concatenate two strings (list or binary). Return type matching the first part.
Return true if What is found in the string
Calculate the Levensthein distance between two strings. Adapted from https://rosettacode.org/wiki/Levenshtein_distance#Erlang to use binary utf8 strings and maps. The smaller the returned integer the closer the strings are. Distance 0 means the two strings are equal.
Return true if Word ends with End
Escape special characters for ical RFC2445 elements
Return the first character of a string.
Check if the variable is a one dimensional list of bytes, or a valid utf-8 binary.
Is the character an ASCII or Unicode whitespace character? See @link https://en.wikipedia.org/wiki/Whitespace_character
Return the last character of a string
Make sure that the string is on one line only, replace control characters with spaces
Transliterate an unicode string to an ascii string with lowercase characters. Tries to transliterate some characters to a..z
Remove all spaces and control characters from a string.
Replace a string inside another string Copyright 2008 Rusty Klophaus (Nitrogen, MIT License)
Sanitize an utf-8 string, remove all non-utf-8 characters.
Split a string, see http://www.erlang.org/pipermail/erlang-questions/2008-October/038896.html
Split the binary into lines. Line separators can be \r, \n or \r\n.
Return true if Start is a prefix of Word
Return a lowercase string for the input
Map a string to a value that can be used as a name or slug. Maps all characters to lowercase and remove non digalpha chars
Filter a filename so that we obtain a basename that is safe to use.
Map a string to a slug that can be used in the uri of a page. Same as a name, but then with dashes instead of underscores.
Return a uppercase string for the input
Remove whitespace at the start and end of the string
Remove all occurrences of a character at the start and end of a string.
Remove whitespace at the start the string
Remove all occurrences of a char at the start of a string
Remove whitespace at the end of the string
Remove all occurrences of a char at the end of the string
Truncate a string. Append the '...' character at the place of break off.
Truncate a string, count all characters. No special handling of entities and tags.
Truncate a string, count all words. No special handling of entities and tags.
Remove the first and last char if they are double quotes.
Link to this section Functions
-spec concat(string() | binary(), string() | binary()) -> string() | binary().
-spec contains(iodata(), iodata()) -> boolean().
-spec distance(S, T) -> Distance
when S :: binary() | string(), T :: binary() | string(), Distance :: non_neg_integer().
-spec ends_with(iodata(), iodata()) -> boolean().
-spec first_char(binary() | list()) -> non_neg_integer().
-spec is_string(iodata()) -> boolean().
-spec is_whitespace(non_neg_integer()) -> boolean().
-spec last_char(binary() | string()) -> non_neg_integer().
-spec len(binary() | string() | undefined) -> integer().
-spec line(string() | binary()) -> string() | binary().
-spec normalize(string() | binary() | atom() | {trans, list()}) -> binary().
-spec nospaces(iodata()) -> iodata().
-spec sanitize_utf8(string() | binary()) -> binary().
-spec split_lines(binary()) -> [binary()].
-spec starts_with(iodata(), iodata()) -> boolean().
-spec to_lower(string() | binary() | atom()) -> binary().
-spec to_name(string() | binary() | atom() | {trans, list()}) -> binary().
-spec to_rootname(file:filename_all()) -> binary().
-spec to_slug(string() | binary() | atom()) -> binary().
-spec to_upper(string() | binary() | atom()) -> binary().
-spec trim(iodata()) -> binary().
-spec trim(iodata(), integer()) -> binary().
-spec trim_left(binary() | list()) -> binary() | list().
-spec trim_left(binary() | list(), integer()) -> binary() | list().
-spec trim_right(iodata()) -> binary().
-spec trim_right(iodata(), integer()) -> binary().
-spec truncate(String :: undefined | string() | binary(), Length :: integer()) -> undefined | binary().
-spec truncate(String :: undefined | string() | binary(),
Length :: integer(),
Append :: binary() | string()) ->
binary().
-spec truncatechars(String :: undefined | string() | binary(), Length :: integer()) ->
undefined | binary().
-spec truncatechars(String :: undefined | string() | binary(),
Length :: integer(),
Append :: binary() | string()) ->
binary().
-spec unquote(iodata()) -> iodata().