<< Prev | - Up - | Next >> |
The module String
contains procedures operating on strings. Strings are lists whose elements are characters (see Section 7.1).
IsString
{String.is
+X
?B
}
tests whether X
is string.
StringToAtom
{String.toAtom
+S
?A
}
converts a string S
to an atom A
. S
must not contain NUL characters. This is the inverse of Atom.toString
(which see).
isAtom
{String.isAtom
+S
?B
}
tests whether the string S
can be converted to an atom.
StringToInt
{String.toInt
+S
?I
}
converts a string S
to an integer I
, according to Oz concrete syntax. See also IntToString
.
isInt
{String.isInt
+S
?B
}
tests whether the string S
can be converted to an integer.
StringToFloat
{String.toFloat
+S
?F
}
converts a string S
to a float F
, according to Oz concrete syntax. See also FloatToString
.
isFloat
{String.isFloat
+S
?B
}
tests whether the string S
can be converted to a float.
token
{String.token
+S1
X
?S2
?S3
}
splits the string S1
into two substrings S2
and S3
. S2
will contain all characters before the first occurence of X
, S3
all remaining characters with X
excluded. If X
does not occur in S1
, then S2
will be equal to S1
and S3
will be the empty string.
For example,
{String.token "a:b:c" &: S1 S2}
binds S1
to "a"
and S2
to "b:c"
.
tokens
{String.tokens
+S
X
?Ss
}
splits the string S
into substrings Ss
delimited by occurrences of X
in S
. Note that the final empty string will be omitted if the last element of S
is an X
.
For example,
{String.tokens "a:bb:cc:d:" &:}
returns ["a" "bb" "cc" "d"]
.
<< Prev | - Up - | Next >> |