module Strutil:String-related utilities.sig
..end
This module provides various helpful utilities for dealing with strings.
Note that this may differ from some other similar functions from
other authors in that:
1. If multiple whitespace characters are present all in a row, they
are all removed;
2. If no whitespace characters are present, nothing is done.
Similar to Str.split_delim.
Example:
For instance,
Author(s): Copyright (C) 2004 John Goerzen
Whitespace removal
These functions are designed to remove extra whitespace from the start
and end of strings. For the purposes of these functions, whitespace
characters are defined as space, tab, carriage return, and line feed.
val strip :
string -> string
val lstrip :
string -> string
val rstrip :
string -> string
Conversions
val split :
string -> string -> string list
# split ":" ":jgoerzen::foo:bar:";;
string list = [""; "jgoerzen"; ""; "foo"; "bar"; ""]
delim
: A string giving the delimiters
: The string to splitval split_ws :
string -> string list
val join :
string -> string list -> string
Returns A list of strings. Each item in the list is one that as
separated by delim. The delim itself will never appear in the list.
Empty strings may be in the list of one instance of delim immediately
followed by another, or if delim occured at the beginning or end of
a string.
val string_of_char :
char -> string
string_of_char 'c'
would produce "c"
.
val string_of_charlist :
char list -> string
string_of_charlist ['h'; 'i']
would produce
"hi"
.
val trunc :
string -> int -> string