Module my_string

My string library.

Copyright © 2003 - 2004 Enrique Marcote Peña

Version: 1.0, {23 Sep 2003} 12:29:46.

Authors: Enrique Marcote Peña (mpquique@users.sourceforge.net) [web site: http://www.des.udc.es/~mpquique/].

Description

My string library.

Additional functions for string processing.

Changes 0.1 -> 0.2

[18 Feb 2004]

Changes 0.2 -> 1.0

[17 Mar 2004] [11 Jun 2004]

Function Index

aequal/2Approximate matching of strings.
aequal/6Approximate matching of strings.
chop_token/2Gets the first token in String, separated by the characters in SeparatorList.
chop_tokens/3Gets the first N tokens in String, separated by the characters in SeparatorList.
is_atime/1Checks if String is a representacion of an absolute time value, given in the format "YYMMDDhhmmsstnnp".
is_dec/1Checks if String is a sequence of decimal digits, every character belongs to [$0, $1, $2, $3, $4, $5, $6, $7, $8, $9].
is_hex/1Checks if String is a sequence of hexadecimal digits, every character belongs to [$0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $A, $B, $C, $D, $E, $F, $a, $b, $c, $d, $e, $f].
is_rtime/1Checks if String is a representacion of a relative time value, given in the format "YYMMDDhhmmsstnnp".
join/2The opposite of string:tokens/2 (sort of).
lowercase/1Returns a new LString where every letter is in lowercase.
normalize/1Returns a new NString where spaces are normalized.
replace_chars/3Replaces on String1 every character in Characters list by Char.
split_by_word/2Splits a String into two parts by a given word.
strip/2

Equivalent to my_string:strip(String, both, SeparatorList).

strip/3Returns a string, where leading and/or trailling characters in SeparatorList have been removed.
uppercase/1Returns a new UString where every letter is in uppercase.

Function Details

aequal/2

aequal(String::String1, Pattern::Pattern) -> Result

Approximate matching of strings. Returs true if String1 is equal to Pattern allowing 1 error (substitution, insertion, deletion or transposition).

> my_string:aequal("hello", "helo").
approximate

See also: aequal/6.

aequal/6

aequal(String::String, Pattern::Pattern, S::Subs, I::Ins, D::Dels, T::Trans) -> Result

Approximate matching of strings. Returs true if String is equal to Pattern allowing Subs substitution errors, Ins insertion errors, Dels deletion errors and Trans transposition errors.

See also: aequal/2.

chop_token/2

chop_token(String::String, SeparatorList::SeparatorList) -> {Token, RestOfString}

Gets the first token in String, separated by the characters in SeparatorList.

See also: chop_tokens/3, string:sub_word/2, string:tokens/2.

chop_tokens/3

chop_tokens(String::String, N::N, SeparatorList::SeparatorList) -> {Tokens, RestOfString}

Gets the first N tokens in String, separated by the characters in SeparatorList. If there are less than N tokens the tuple {AvailableTokens, "" } is returned.

See also: chop_token/2, string:sub_word/2, string:tokens/2.

is_atime/1

is_atime(String::String) -> bool()

Checks if String is a representacion of an absolute time value, given in the format "YYMMDDhhmmsstnnp". Where

YY
00 - 99
MM
01 - 12
DD
01 - 31
hh
00 - 23
mm
00 - 59
ss
00 - 59
t
0 - 9
nn
00 - 48
p
+ | -

If String is empty, true is returned.

See also: is_rtime/1.

is_dec/1

is_dec(Rest::String) -> bool()

Checks if String is a sequence of decimal digits, every character belongs to [$0, $1, $2, $3, $4, $5, $6, $7, $8, $9].

If String is empty, true is returned.

See also: is_hex/1.

is_hex/1

is_hex(Rest::String) -> bool()

Checks if String is a sequence of hexadecimal digits, every character belongs to [$0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $A, $B, $C, $D, $E, $F, $a, $b, $c, $d, $e, $f].

If String is empty, true is returned.

See also: is_dec/1.

is_rtime/1

is_rtime(String::String) -> bool()

Checks if String is a representacion of a relative time value, given in the format "YYMMDDhhmmsstnnp". Where

YY
00 - 99
MM
01 - 12
DD
01 - 31
hh
00 - 23
mm
00 - 59
ss
00 - 59
t
0
nn
00
p
R

If String is empty, true is returned.

See also: is_atime/1.

join/2

join(List::List, Sep::Sep) -> String

The opposite of string:tokens/2 (sort of).

Written by Per Hedeland at erlang-questions.

lowercase/1

lowercase(String::String) -> LString

Returns a new LString where every letter is in lowercase.

See also: uppercase/1.

normalize/1

normalize(String::String) -> NString

Returns a new NString where spaces are normalized.

replace_chars/3

replace_chars(String::String1, Characters::Characters, Char::Char) -> String2

Replaces on String1 every character in Characters list by Char.

> replace_chars("hello_world.", "_.", $ ).
"hello world "

split_by_word/2

split_by_word(String::String, N::Number) -> {Prefix, Suffix}

Splits a String into two parts by a given word. Prefix contains Number words and Suffix the rest of the string. Words are separated by blanks.

String == Prefix ++ Suffix

strip/2

strip(String::String, SeparatorList::SeparatorList) -> Stripped

Equivalent to my_string:strip(String, both, SeparatorList).

strip/3

strip(String::String, X2::Direction, SeparatorList::SeparatorList) -> Stripped

Returns a string, where leading and/or trailling characters in SeparatorList have been removed. Direction can be left, right or both and indicates from which direction characters are to be removed. The function strip/2 is equivalent to strip(String, both, SeparatorList).

See also: string:strip/1, string:strip/2, string:strip/3.

uppercase/1

uppercase(String::String) -> UString

Returns a new UString where every letter is in uppercase.

See also: lowercase/1.