[Type] String
Part of library: mobl
Inherits from: mobl::Object
The String
type represents textual values.
Operators
+
Concatenates two string values.
Example:
var s = "Hello, ";
var s2 = s + "You!";
s2 // -> "Hello, You!"
Instance methods
charAt(index : Num) : String
Retrieves the index
-th character of the string.
Example:
var s = "ABC";
s.charAt(1) // -> "B"
charCodeAt(index : Num) : Num
Returns the character code (ordinal value) of the character at position index
.
Example:
var s = "ABC";
s.charCodeAt(0) // -> 65
indexOf(searchstring : String, start : Num = 0) : Num
Searches the string for the first instance of searchstring
, optionally starting from offset start
:
Example:
var s = "ABCABC";
s.indexOf("BC") // -> 1
s.indexOf("BC", 2) // -> 4
lastIndexOf(searchstring : String, start : Num = 0) : Num
Searches the string for the last instance of searchstring
.
Example:
var s = "ABCABC";
s.lastIndexOf("BC") // -> 4
match(regexp : RegExp) : Array<String>
Example:
replace(regexp : RegExp, newstring : String) : String
Example:
replace(substr : String, newstring : String) : String
Example:
search(regexp : RegExp) : Num
Example:
slice(start : Num, end : Num) : String
Example:
split(separator : String, limit : Num = 1000) : Array<String>
Example:
substr(start : Num, length : Num) : String
Example:
substring(from : Num, to : Num) : String
Example:
toLowerCase() : String
Example:
toUpperCase() : String
Example:
Instance properties
length
Contains the length of the string.
Example:
var s = "abc";
s.length // -> 3
mobl/string.txt · Last modified: 2013/10/01 02:28 (external edit)