Module z_string

String related functions.

Copyright © 2009-2020 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl).

Description

String related functions

Function Index

concat/2Concatenate two strings (list or binary).
contains/2Return true if What is found in the string.
ends_with/2Return true if Word ends with End.
escape_ical/1Escape special characters for ical RFC2445 elements.
first_char/1Return the first character of a string.
is_string/1Check if the variable is a one dimensional list of bytes, probably a string.
is_whitespace/1Is the character an ASCII or Unicode whitespace character? See @link https://en.wikipedia.org/wiki/Whitespace_character.
last_char/1Return the last character of a string.
len/1
line/1Make sure that the string is on one line only, replace control characters with spaces.
nospaces/1Remove all spaces and control characters from a string.
replace/3Replace a string inside another string Copyright 2008 Rusty Klophaus (Nitrogen, MIT License).
sanitize_utf8/1Sanitize an utf-8 string, remove all non-utf-8 characters.
split/2Split a string, see http://www.erlang.org/pipermail/erlang-questions/2008-October/038896.html.
split_lines/1Split the binary into lines.
starts_with/2Return true if Start is a prefix of Word.
to_lower/1Return a lowercase string for the input.
to_name/1Map a string to a value that can be used as a name or slug.
to_rootname/1Filter a filename so that we obtain a basename that is safe to use.
to_slug/1Map a string to a slug that can be used in the uri of a page.
to_upper/1Return a uppercase string for the input.
trim/1Remove whitespace at the start and end of the string.
trim/2Remove all occurences of a character at the start and end of a string.
trim_left/1Remove whitespace at the start the string.
trim_left/2Remove all occurences of a char at the start of a string.
trim_left_func/2
trim_right/1Remove whitespace at the end of the string.
trim_right/2Remove all occurences of a char at the end of the string.
truncate/2Truncate a string.
truncate/3
truncatewords/2
truncatewords/3
unquote/1Remove the first and last char if they are double quotes.
unquote/2

Function Details

concat/2

concat(A::string() | binary(), B::string() | binary()) -> string() | binary()

Concatenate two strings (list or binary). Return type matching the first part.

contains/2

contains(What::String, B::String) -> bool()

Return true if What is found in the string

ends_with/2

ends_with(End::String, B::String) -> bool()

Return true if Word ends with End

escape_ical/1

escape_ical(L) -> any()

Escape special characters for ical RFC2445 elements

first_char/1

first_char(L::binary() | list()) -> pos_integer()

Return the first character of a string.

is_string/1

is_string(Rest::list()) -> boolean()

Check if the variable is a one dimensional list of bytes, probably a string

is_whitespace/1

is_whitespace(C::non_neg_integer()) -> boolean()

Is the character an ASCII or Unicode whitespace character? See @link https://en.wikipedia.org/wiki/Whitespace_character

last_char/1

last_char(L::binary() | string()) -> pos_integer()

Return the last character of a string

len/1

len(L::binary() | string() | undefined) -> integer()

line/1

line(B::string() | binary()) -> string() | binary()

Make sure that the string is on one line only, replace control characters with spaces

nospaces/1

nospaces(B::binary() | string()) -> binary() | string()

Remove all spaces and control characters from a string.

replace/3

replace(String, S1, S2) -> any()

Replace a string inside another string Copyright 2008 Rusty Klophaus (Nitrogen, MIT License)

sanitize_utf8/1

sanitize_utf8(L::string() | binary()) -> binary()

Sanitize an utf-8 string, remove all non-utf-8 characters.

split/2

split(String, L::String) -> list()

Split a string, see http://www.erlang.org/pipermail/erlang-questions/2008-October/038896.html

split_lines/1

split_lines(B) -> any()

Split the binary into lines. Line separators can be \r, \n or \r\n.

starts_with/2

starts_with(Start::String, B::String) -> bool()

Return true if Start is a prefix of Word

to_lower/1

to_lower(B::string() | binary() | atom()) -> binary()

Return a lowercase string for the input

to_name/1

to_name(V::string() | binary() | atom()) -> binary()

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

to_rootname/1

to_rootname(Filename::file:filename_all()) -> binary()

Filter a filename so that we obtain a basename that is safe to use.

to_slug/1

to_slug(Title::string() | binary() | atom()) -> binary()

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.

to_upper/1

to_upper(B::string() | binary() | atom()) -> binary()

Return a uppercase string for the input

trim/1

trim(B::binary() | list()) -> binary() | list()

Remove whitespace at the start and end of the string

trim/2

trim(B::binary() | list(), Char::integer()) -> binary() | list()

Remove all occurences of a character at the start and end of a string.

trim_left/1

trim_left(S::binary() | list()) -> binary() | list()

Remove whitespace at the start the string

trim_left/2

trim_left(S::binary() | list(), Char::integer()) -> binary() | list()

Remove all occurences of a char at the start of a string

trim_left_func/2

trim_left_func(Bin, F) -> any()

trim_right/1

trim_right(B::binary() | list()) -> binary() | list()

Remove whitespace at the end of the string

trim_right/2

trim_right(B::binary() | list(), Char::integer()) -> binary() | list()

Remove all occurences of a char at the end of the string

truncate/2

truncate(String::undefined | string() | binary(), Length::integer()) -> undefined | binary()

Truncate a string. Append the '...' character at the place of break off.

truncate/3

truncate(String::undefined | string() | binary(), Length::integer(), Append::binary() | string()) -> binary()

truncatewords/2

truncatewords(S, Words) -> any()

truncatewords/3

truncatewords(S, Words, Append) -> any()

unquote/1

unquote(S::string() | binary()) -> string() | binary()

Remove the first and last char if they are double quotes.

unquote/2

unquote(S, Q) -> any()


Generated by EDoc