The string class represents character strings.
String is a sequence of characters.
Constructor
Creates new string from the string representation of given parameter.
Methods
Capitalizes the first character of all words.
Capitalizes first character of first word.
Returns single character from this string.
| Parameters |
index -
Index to string
|
Returns the character code at the speicified index.
| Parameters |
index -
Index to string
|
Chops suffix out of string.
Compares this string and given string, lower- and
uppercase characters are considered equal.
| Returns |
-1 if this<other,
0 if this==other,
1 if this>other, |
Compresses consequtive white space characeters into single
space.
Checks if some region of this string matches given
regular expression.
| Parameters |
pattern -
Regular expression pattern
|
| Returns |
Matches or boolean |
| Throws |
MalformedPattern -
If pattern is invalid
|
Decodes URL encoding from this string.
Decodes URI encoding from this string.
Decodes URL encoding from this string.
Divides string to two pieces, using delim as delimiter.
Example 1. "foo.bar.foo".divide(".") returns ("foo", "bar.foo")
Example 2. "foo.bar.foo".divide("|") returns ("foo.bar.foo", null)
Example 3. "foo.bar.fiu".divide(".", true) return ("fiu", "foo.bar")
| Parameters |
delim -
Delimiter character(s)
dir -
Direction (default false), false = from start of the string,
true = from end of the string
|
Removes given prefix out of string.
URL encodes this string.
binary encodeTo(
string encoding)
Encodes this string to binary using given character encoding,
throws IOError if string cannot be mapped
binary encodeTo(
string encoding,
binary replacement)
Encodes this string to binary using given character encoding,
unmappable characters are replaced with given binary
binary encodeTo(
string encoding,
string replacement)
Encodes this string to binary using given character encoding,
unmappable characters are replaced with given string
binary encodeTo(
string encoding,
null ignore)
Encodes this string to binary using given character encoding,
unmappable characters are ignored.
| Throws |
BadParameter -
if given character encoding is unsupported,
or replacement is invalid
IOError -
if some characters are unmappable and no replacement given
|
URI encodes this string.
URL encodes this string.
Checks if this string ends with given suffix.
Checks if this string is equal to given string, lower- and
uppercase characters are considered equal
| Parameters |
other -
String to compare with
|
Escapes string using the rules of anvil string literal.
Splits this string into regions using given set of delimiter
characters.
| Parameters |
delimiters -
Set of delimiter characters
returnEmpty -
If true also empty regions are returned, if
omitted or false empty regions are not returned.
|
Finds all regions from this string mathing given regular
expression pattern.
| Parameters |
pattern -
Regular expression pattern
|
| Returns |
Iterator of strings |
| Throws |
MalformedPattern -
If pattern is invalid
|
Converts string to binary,
assuming that two characters produce one byte: 414243 -> binary(abc)
Returns the index within this string of the first occurrence of the
specified string.
| Parameters |
needle -
String to search for
fromIndex -
Starting index of search
|
| Returns |
The index of first occurence, or -1 if it doesn't occur. |
Returns the index within this string of the last occurrence of the
specified string.
| Parameters |
needle -
String to search for
fromIndex -
Starting index of search
|
| Returns |
The index of last occurence, or -1 if it doesn't occur. |
Returns the length of this string.
Checks if this (whole) string matches given
regular expression.
| Parameters |
pattern -
Regular expression pattern
|
| Returns |
Matches or boolean |
| Throws |
MalformedPattern -
If pattern is invalid
|
Convers all line feeds into <br>
Converts white spaces into .
Pads text left or right to field.
| Parameters |
length -
Length of field, positive for right padding, negative
for left padding.
padding -
Padding character, default is space.
|
| Returns |
Given text padded to field |
Converts all applicable characters with corresponding
html entity.
Converts all applicable characters under >127 with corresponding
html entity.
Converts all applicable characters over >127 with corresponding
html entity.
Repeats this string amount times.
Replaces all occurences of from into to.
| Parameters |
from -
Regions to replace
to -
Replacement
|
Splits this string using given regular expression pattern as
delimiter.
| Parameters |
pattern -
Regular expression pattern
|
| Throws |
MalformedPattern -
If pattern is invalid
|
Checks if this string starts with given prefix.
Removes all tags, comments and processing instructions from
string.
Removes all tags comments and processing instructions from
string. Additionally text content inside <script>, <style>
and <head> are removed, exlucing <title>.
Substitutes all regions from this string matching given
regular expression.
| Parameters |
pattern -
Regular expression pattern
replacement -
Either a string or a function:
function replacer(list matchedGroups).
amount -
Number of occurences to replace, if omitted, all occurences are substituted.
|
| Throws |
MalformedPattern -
If pattern is invalid
|
Substitutes first region from this string matching given
regular expression.
| Parameters |
pattern -
Regular expression pattern
replacement -
Replacement string
replacer -
Replace function:
function replacer(list matchedGroups).
|
| Throws |
MalformedPattern -
If pattern is invalid
|
Returns a substring from the given region of this string.
| Parameters |
start -
Starting index, included
end -
Ending index, excluded
|
Converts all upper case characeters into corresponding lower case
characeters.
Converts all lower case characeters into corresponding upper case
characeters.
For each character in this string: if character appears
in from string, converts it to character
at the same index at to.
| Parameters |
from -
Source character mapping
to -
Target character mapping
|
| Returns |
Translated string |
Removes whitespace characters from the beginning and end of this string.
Removes whitespace characters from the beginning this string.
Removes whitespace characters from the end this string.
Unescapes backslash quotes.
Unquotes all html entities from this string.
Unserializes data contained in this string.
| Returns |
Unserialized data |
| Throws |
CorruptedSerialization -
If serialized data is corrupted
|
Converts all applicable characters with corresponding
html entity.
Converts all applicable characters over >127 with corresponding
html entity.