string.eh
String operations. More...
Functions
Description
String is a sequence of unicode characters. Every character is a number in
range 0..65535. Strings are immutable, once created string cannot change.
If you need changeable strings, use either
StrBuf or [
Char].
Starting from release 2.0, you can use square brackets []
to get
individual character or substring:
Function details
Returns string representing this
Int
as an unsigned binary number.
Returns string representing this
Int
as an unsigned octal number.
Returns string representing this
Int
as an unsigned hexadecimal number.
Returns string representing this
Int
as a signed number in the given base.
Argument
base should be in range 2..36.
Returns string representing this
Long
as a signed number in the given base.
Argument
base should be in range 2..36.
Parses this string as a signed decimal integer.
If string is not representing valid number, then
null
is returned.
def String.tointbase(base: Int): Int;
|
Parses this string as a signed integer in the given base.
Argument @emph base should be in range 2..36.
def String.tolong(): Long;
|
Parses this string as a signed decimal long integer.
If string is not representing valid number, then
null
is returned.
def String.tolongbase(base: Int): Long;
|
Parses this string as a signed long integer in the given base.
Argument
base should be in range 2..36.
def String.tofloat(): Float;
|
Parses this string as a single precision floating point number.
If string is not representing valid number, then
null
is returned.
def String.todouble(): Double;
|
Parses this string as a double precision floating point number.
If string is not representing valid number, then
null
is returned.
Returns index of the first occurence of given character in the string.
If string does not contain given character then -1 is returned.
def String.lindexof(ch: Char): Int;
|
Returns index of the last occurence of given character in the string.
If string does not contain given character then -1 is returned.
Tests if this string starts with the specified prefix.
If offset is given, prefix string is tested at the corresponding position of this string.
Tests if the string ends with the specified suffix.
Returns new string where all occurences of the old character are replaced by new character.
Returns index of the first occurence of given substring in the string.
If string does not contain given substring then -1 is returned.
Returns string with all characters converted to the upper case.
Returns string with all characters converted to the lower case.
Concatenates this string with another string.
The same is done by operator '+'.
Compares this string with another string lexicographically.
Returns zero if two strings are equal, value less than zero if this string
is less than argument and value greater than zero if this string is greater
than argument.
Removes all whitespaces from the beginning and the end of the stream.
This includes removing of
' '
,
'\t'
,
'\r'
and
'\n'
.
Splits the string around given character.
Examples:
"foo,and,baaz".split(',')
"foo,and,baaz".split('a')
|
Returns formatted string using this string as format specification and given arguments.
Format specifiers are substrings of the form
%n
where
n
is from
0 to 9. Each format specifier is substituted with corresponding value from
array
args. Specifier
%%
is substituted with percent character.
For example:
"The price of %0 has decreased by %1%%".format(["cookies", 8])
|
def String.chars(): [Char];
|
Returns characters of this string as character array.
def String.utfbytes(): [Byte];
|
Encodes this string in modified UTF-8 format and returns it as byte array.
Computes 32-bit hash of this string using default Java hashing algorithm.
Creates new string with characters given from specified character array.
Decodes byte sequence as string in modified UTF-8 format.