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

find/2Equivalent to find(String, SearchPattern, leading).
find/3
split/2Equivalent to split(String, Pattern, leading).
split/3Splits String where SearchPattern is encountered and return the remaining parts.
to_lower/1Convert string or character to uppercase.
to_upper/1Convert string or character to uppercase.
trim/1Equivalent to trim(String, both).
trim/2Returns a string, where leading or trailing, or both, whitespace has been removed.

Function Details

find/2


find(String::unicode:chardata(), SearchPattern::unicode:chardata()) -> unicode:chardata() | nomatch

String: string to search in
SearchPattern: pattern to search

returns: remainder of String starting from first occurrence of SearchPattern or nomatch if SearchPattern cannot be found in String

Equivalent to find(String, SearchPattern, leading).

find/3


find(String::unicode:chardata(), SearchPattern::unicode:chardata(), Direction::leading | trailing) -> unicode:chardata() | nomatch

String: string to search in
SearchPattern: pattern to search
Direction: direction to search, leading or trailing

returns: remainder of String starting from first or last occurrence of SearchPattern or nomatch if SearchPattern cannot be found in String

split/2


split(String::unicode:chardata(), Pattern::unicode:chardata()) -> [unicode:chardata()]

String: a string to split
Pattern: the search pattern to split at

returns: chardata

Equivalent to split(String, Pattern, leading).

split/3


split(String::unicode:chardata(), Pattern::unicode:chardata(), Where::leading | trailing | all) -> [unicode:chardata()]

String: a string to split
Pattern: the search pattern to split at
Where: 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 trim
Direction: 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">>