String - Kirix Documentation

Developer Resources

String

Overview

A class that represents string-typed data.

Base Class

Object

Constructor

String()
String(value : String)

Arguments

value
The value of the new String object.

Methods

String.charAt
Returns the character at the specified position.
String.charCodeAt
Returns the unicode encoding of the character at the specified position.
String.compare
Returns an integer indicating whether the current string is less than, equal to, or greater than a specified.
String.concat
Concatenates a number of values to the string.
String.fromCharCode
Returns a string created by converting all arguments to characters and concatenating them.
String.indexOf
Returns the position of the first occurrence of the specified text in the string.
String.lastIndexOf
Returns the position of the last occurrence of the specified text in the string.
String.localeCompare
Returns an integer indicating whether the current string is less than, equal to, or greater than a specified.
String.match
Searches for the specified pattern in the string.
String.replace
Replaces matching text in a string with the text of another string.
String.search
Searches for the specified pattern in the string.
String.slice
Returns a substring of the string.
String.split
Returns an array obtained by splitting the string at the instances of the specified character.
String.sprintf
Returns a string formatted by a specified format string
String.substr
Returns a substring of the string.
String.substring
Returns a substring of the string.
String.toLowerCase
Returns a copy of the string with all lowercase characters.
String.toString
Returns the primitive string value.
String.toUpperCase
Returns a copy of the string with all uppercase characters.
String.trim
Returns a string with leading and trailing spaces removed
String.valueOf
Returns the primitive string value.

Inherited Methods

Object.hasOwnProperty
Checks for the existence of an object property
Object.toLocaleString
Returns a string that represents the object.
Object.toString
Returns a string that represents the object.
Object.valueOf
Returns the 'primitive' value of the object.

String.charAt

function String.charAt(index : Integer) : String

Arguments

index
The character to return at the position given by index.

Returns

Returns the character at the specified position.

Description

Returns the character at the specified, zero-based index in the string.

String.charCodeAt

function String.charCodeAt(index : Integer) : Integer

Arguments

index
The zero-based index of the character of the string whose unicode encoding is to be returned.

Returns

Returns the unicode encoding of the character at the specified index.

Description

Returns the unicode encoding of the character at the specified index.

String.compare

function String.compare(string : String) : Integer
static function String.compare(string1 : String, string2 : String) : Integer

Arguments

string
The string to which to compare the current string.

Returns

Returns an integer indicating whether the current string is less than, equal to, or greater than a specified.

Description

Returns an integer indicating whether the current string is less than, equal to, or greater than a specified string. If the current string is less than the specified string, the return result is negative; if the current string is equal to the specified string, the return result is zero; if the current string is greater than the specified string, the return result is positive. If the static function is used, string1 is compared with string2. Note: this function is equivalent to localeCompare().

String.concat

function String.concat(str_1 : String, ..., str_n : String) : String

Arguments

str_1, ..., str_n
The elements to concatenate with this string.

Returns

A string resulting from concatenating the current string with the input elements.

Description

Concatenates the elements str_1, ..., str_n with the current string and returns the results as a new string.

String.fromCharCode

static function String.fromCharCode(char_1 : Integer, ..., char_n : Integer) : String

Arguments

char_1, ..., char_n
A number of integers that are the unicode character encodings of the characters to which they are to be converted.

Returns

Returns a string created by converting all arguments to characters and concatenating them.

Description

Returns a string created by converting all arguments to characters and concatenating them.

String.indexOf

function String.indexOf(text : String) : Integer
function String.indexOf(text : String, index : Integer) : Integer

Arguments

text
The text to search for in the string.
index
The index at which to start the search. If this argument is not supplied, 0 is taken as the default value.

Returns

Returns the position of the first occurrence of text in the string after the starting index. If the text cannot be found, the function returns -1.

Description

Returns the position of the first occurrence of text in the string after the starting index. If text cannot be found, the function returns -1.

String.lastIndexOf

function String.lastIndexOf(text : String) : Integer
function String.lastIndexOf(text : String, index : Integer) : Integer

Arguments

text
The text to search for in the string.
index
The index at which to start the search. If this argument is not supplied, 0 is taken as the default value.

Returns

Returns the position of the last occurrence of text in the string after the starting index. If the text cannot be found, the function returns -1.

Description

Returns the position of the last occurrence of text in the string after the starting index. If text cannot be found, the function returns -1.

String.localeCompare

function String.localeCompare(string : String) : Integer
static function String.localeCompare(string1 : String, string2 : String) : Integer

Arguments

string
The string to which to compare the current string.

Returns

Returns an integer indicating whether the current string is less than, equal to, or greater than a specified.

Description

Returns an integer indicating whether the current string is less than, equal to, or greater than a specified string. If the current string is less than the specified string, the return result is negative; if the current string is equal to the specified string, the return result is zero; if the current string is greater than the specified string, the return result is positive. If the static function is used, string1 is compared with string2. Note: this function is equivalent to compare().

String.match

function String.match(regexp : RegExp) : Array(String)

Arguments

regexp
A regular expression with which to search the current string.

Returns

Returns an array containing the results of searching the current string with the regular expression regexp. Returns null if no matches are found.

Description

Searches the string for the regular expression specified by regexp and returns the results of the match in an array. If no matches are found, the function returns null.

String.replace

function String.replace(param : RegExp, text : String) : String
function String.replace(param : String, text : String) : String

Arguments

param
A String or RegExp that is to be used to search the current string and whose matches are to be replaced with text. If param is a RegExp and the global flag is set, all matching strings are replaced. If param is is a String, only the first matching string is replaced.
text
The text that is to replace the matches of param.

Returns

A new string consisting of the text of the original String, with one or more occurrences of param replaced with text.

Description

This function returns a new string, where the text in the new string is the text of the original string with the portions of replaced text. The portions of replaced text are determined by finding matches in the original string with the param, where the param is either a regular expression or literal text.

String.search

function String.search(regexp : RegExp) : Integer

Arguments

regexp
A regular expression object that is to be used to search the current string.

Returns

Returns the position of the first match of regexp or -1 if no match was found.

Description

Returns the position of the first match of regexp or -1 if no match was found.

String.slice

function String.slice(start : Integer, end : Integer) : String

Arguments

start
The position at which the slice is to start.
end
The position before which the slice is to end.

Returns

A string containing the characters between start and end including the former but excluding the latter. If start or end is negative, the result of adding the negative number to the length of string is used.

Description

A string containing the characters between start and end including the former but excluding the latter. If start or end is negative, the result of adding the negative number to the length of string is used.

String.split

function String.split(delimiter : String, limit : Integer) : Array(String)

Arguments

delimiter
The string at whose occurrences the current string is to be split.
limit
The maximum number of elements the returned array can have.

Returns

Returns an array containing string split up at the occurrences of the delimiter.

Description

Returns an array containing string split up at the occurrences of the delimiter, where the maximum number of elements that can be returned in the array is given by limit.

String.sprintf

static function String.sprintf(format : String, val1 : Any, val2 : Any, ...) : String

Arguments

format
The format string contains the output string with formatting specifiers.

Returns

Returns a formatted string

Description

String.sprintf() formats a string specified in the format parameter by inserting values in the manner indicated by the formatting specifiers. Please note that method is not a standard ECMAScript String method.

String.substr

function String.substr(start : Integer) : String
function String.substr(start : Integer, length : Integer) : String

Arguments

start
The position at which the returned substring is to start.
length
The length of the returned substring.

Returns

Returns a string containing the length characters of the current string starting at position start. If length is not supplied, all characters after start are included in the returned string.

Description

Returns a string containing the length characters of the current string starting at position start. If length is not supplied, all characters after start are included in the returned string.

String.substring

function String.substring(start : Integer) : String
function String.substring(start : Integer, end : Integer) : String

Arguments

start
The position at which the returned substring is to start.
end
The position at which the returned substring is to end.

Returns

Returns a string containing the characters of the current string from the start position to the position right before end.

Description

Returns a string containing the characters of the current string from the start position to the position right before end. If end isn't specified, the function returns the string from start to the end of the string.

String.toLowerCase

function String.toLowerCase() : String

Returns

Returns a copy of the string with all lowercase characters.

Description

Returns a copy of the string with all lowercase characters.

String.toString

function String.toString() : String

Returns

Returns the primitive string value associated with the String.

Description

Returns the primitive string value associated with the String.

String.toUpperCase

function String.toUpperCase() : String

Returns

Returns a copy of the string with all uppercase characters.

Description

Returns a copy of the string with all uppercase characters.

String.trim

function String.toLowerCase() : String

Returns

A copy of the string with leading and trailing spaces removed.

Description

Returns a copy of the string with all leading and trailing spaces removed. Any white space or line separating character constitues a "space".

String.valueOf

function String.valueOf() : String

Returns

Returns the primitive string value associated with the String.

Description

Returns the primitive string value associated with the String.