Module string
An implementation of the Erlang/OTP string interface.
Description
This module implements a strict subset of the Erlang/OTP string interface.
Function Index
split/2 | Equivalent to split(String, Pattern, leading). |
split/3 | Splits String where SearchPattern is encountered and return the remaining parts. |
to_lower/1 | Convert string or character to uppercase. |
to_upper/1 | Convert string or character to uppercase. |
trim/1 | Equivalent to trim(String, both). |
trim/2 | Returns a string, where leading or trailing, or both, whitespace has been removed. |
Function Details
split/2
split(String::string(), Pattern::string()) -> string() | char()
String
: a string to splitPattern
: the search pattern to split at
returns: chardata
Equivalent to split(String, Pattern, leading)
.
split/3
split(String::string(), Pattern::string() | char(), Where::atom()) -> string() | char()
String
: a string to splitPattern
: the search pattern to split atWhere
: position to split (leading, trailing, or all)
returns: chardata
Splits String where SearchPattern is encountered and return the remaining parts.
Where, default leading, indicates whether the leading, the trailing or all encounters of SearchPattern will split String.
Example:
0> string:split("ab..bc..cd", "..").
["ab","bc..cd"]
1> string:split(<<"ab..bc..cd">>, "..", trailing).
[<<"ab..bc">>,<<"cd">>]
2> string:split(<<"ab..bc....cd">>, "..", all).
[<<"ab">>,<<"bc">>,<<>>,<<"cd">>]
to_lower/1
to_lower(Input::string() | char()) -> string() | char()
Input
: a string or character to convert
returns: a Character or string
Convert string or character to uppercase.
The specified string or character is case-converted. Notice that the supported character set is ISO/IEC 8859-1 (also called Latin 1); all values outside this set are unchanged
to_upper/1
to_upper(Input::string() | char()) -> string() | char()
Input
: a string or character to convert
returns: a Character or string
Convert string or character to uppercase.
The specified string or character is case-converted. Notice that the supported character set is ISO/IEC 8859-1 (also called Latin 1); all values outside this set are unchanged
trim/1
trim(String::string()) -> string() | char()
String
: a string or character to trim whitespace
returns: a Character or string
Equivalent to trim(String, both)
.
trim/2
trim(String::string, Direction::atom()) -> string() | char()
String
: a string or character to trimDirection
: an atom indicating the direction from which to remove whitespace
returns: a Character or string
Returns a string, where leading or trailing, or both, whitespace has been removed.
If omitted, Direction is both.
Example:
1> string:trim("\t Hello \n").
"Hello"
2> string:trim(<<"\t Hello \n">>, leading).
<<"Hello \n">>
3> string:trim(<<".Hello.\n">>, trailing, "\n.").
<<".Hello">>