Size: 3175
Comment:
|
Size: 7632
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
The following can be used to manipulate and retrieve details from variables. '''Each of these functions can be used with a variable as follows:''' . ''varName.method'' The .method at the end is how you will specify which function you are using. Using the table below, you could for example find out the 4th letter of the variable named var that has stored the word "hello" like so: {{{ var="hello" echo var.charAt(4) Result (with debug): 01:19:02 Running line 1 01:19:02 var = hello 01:19:03 Running line 2 01:19:03 o 01:19:04 Script stopped }}} |
The following functions can be used to manipulate and retrieve string details from objects and variables. These should be written in the following formats: .''variable.method(arguments)'', example - ''myVar.subStr(3,2)'' if your variable name was "myVar" and you wanted to use subStr() to find the 2 characters that begin 3 from the left. .''object.method(arguments)'', example - ''city.coords.split(",")'' if you wanted to split the coordinates of your city into an array to determine the seperate x and y values using the split() function. |
Line 22: | Line 9: |
||<tablewidth="796px" tableheight="123px"#cccccc>'''Method ''' ||<#cccccc>'''Type''' ||<#cccccc>'''Description ''' ||||<style="text-align:center"> || ||charAt ||String ||Returns the character in the position specified by the index parameter. || ||charCodeAt ||Number ||Returns the numeric Unicode character code of the character at the specified index. || ||concat ||String ||Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string. || ||fromCharCode ||String ||Returns a string comprising the characters represented by the Unicode character codes in the parameters. || ||indexOf ||int ||Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string. || ||lastIndexOf ||int ||Searches the string from right to left and returns the index of the last occurrence of val found before startIndex. || ||localeCompare ||int ||Compares the sort order of two or more strings and returns the result of the comparison as an integer. || ||match ||Array ||Matches the specifed pattern against the string. || ||replace ||String ||Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl. || ||search ||int ||Searches for the specifed pattern and returns the index of the first matching substring. || ||slice ||String ||Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character. || ||split ||Array ||Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs. || ||substr ||String ||Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len. || ||substring ||String ||Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1. || ||toLocaleLowerCase ||String ||Returns a copy of this string, with all uppercase characters converted to lowercase. || ||toLocaleUpperCase ||String ||Returns a copy of this string, with all lowercase characters converted to uppercase. || ||toLowerCase ||String ||Returns a copy of this string, with all uppercase characters converted to lowercase. || ||toUpperCase ||String ||Returns a copy of this string, with all lowercase characters converted to uppercase. || ||valueOf ||String ||Returns the primitive value of a String instance. || |
||<tablewidth="796px" tableheight="123px"#cccccc>'''Method ''' ||<#cccccc>'''Type''' ||<#cccccc>'''Description '''||||<style="text-align:center"> || || ||[[#charAt|charAt]] ||String ||Returns the character in the position specified by the index parameter. || ||[[#charCodeAt|charCodeAt]] ||Number ||Returns the numeric Unicode character code of the character at the specified index. || ||[[#concat|concat]] ||String ||Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string. || ||[[#fromCharCode|fromCharCode]] ||String ||Returns a string comprising the characters represented by the Unicode character codes in the parameters. || ||[[#indexOf|indexOf]] ||int ||Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string. || ||[[#lastIndexOf|lastIndexOf]] ||int ||Searches the string from right to left and returns the index of the last occurrence of val found before startIndex. || ||[[#localeCompare|localeCompare]] ||int ||Compares the sort order of two or more strings and returns the result of the comparison as an integer. || ||[[#match|match]] ||Array ||Matches the specifed pattern against the string. || ||[[#replace|replace]] ||String ||Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl. || ||[[#search|search]] ||int ||Searches for the specifed pattern and returns the index of the first matching substring. || ||[[#slice|slice]] ||String ||Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character. || ||[[#split|split]] ||Array ||Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs. || ||[[#substr|substr]] ||String ||Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len. || ||[[#substring|substring]] ||String ||Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1. || ||[[#toLocaleLowerCase|toLocaleLowerCase]] ||String ||Returns a copy of this string, with all uppercase characters converted to lowercase. || ||[[#toLocaleUpperCase|toLocaleUpperCase]] ||String ||Returns a copy of this string, with all lowercase characters converted to uppercase. || ||[[#toLowerCase|toLowerCase]] ||String ||Returns a copy of this string, with all uppercase characters converted to lowercase. || ||[[#toUpperCase|toUpperCase]] ||String ||Returns a copy of this string, with all lowercase characters converted to uppercase. || ||[[#valueOf|valueOf]] ||String ||Returns the primitive value of a String instance. || = charAt = '''Usage:''' charAt(#) Returns the character in the position specified by the index parameter. '''Example:''' .// Don't forget almost all internal "counting" starts at 0, not at 1... .// so the 5th character would actually be 0, 1, 2, 3, '''4''' <--- 4! .var="hello" .echo "The 5th letter in the word hello is: " + var.charAt(4) '''Result:''' .00:49:44 The 5th letter in the word hello is: o .00:49:45 Script stopped = charCodeAt = '''Usage:''' charCodeAt(#) Returns the numeric Unicode character code of the character at the specified index. '''Example:''' .var="hello" .echo "The numeric code of the 5th letter in the word hello is: " + var.charCodeAt(4) '''Result:''' .01:04:27 The numeric code of the 5th letter in the word hello is: 111 .01:04:28 Script stopped = concat = '''Usage:''' concat(arg1,arg2,...,argN) Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string. '''Example:''' .var="oompa" .var2="loompa" .var3="dance" .echo var.concat(var2," ",var3) '''Result:''' .01:06:48 oompaloompa dance .01:06:49 Script stopped = fromCharCode = '''Usage:''' Returns a string comprising the characters represented by the Unicode character codes in the parameters. '''Example:''' . '''Result:''' . = indexOf = '''Usage:''' Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string. '''Example:''' . '''Result:''' . = lastIndexOf = '''Usage:''' Searches the string from right to left and returns the index of the last occurrence of val found before startIndex. '''Example:''' . '''Result:''' . = localeCompare = '''Usage:''' Compares the sort order of two or more strings and returns the result of the comparison as an integer. '''Example:''' . '''Result:''' . = match = '''Usage:''' Matches the specifed pattern against the string. '''Example:''' . '''Result:''' . = replace = '''Usage:''' Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl. '''Example:''' . '''Result:''' . = search = '''Usage:''' Searches for the specifed pattern and returns the index of the first matching substring. '''Example:''' . '''Result:''' . = slice = '''Usage:''' Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character. '''Example:''' . '''Result:''' . = split = '''Usage:''' Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs. '''Example:''' .mycoords=city.coords.split(",") .echo "x:" + mycoords[0] + " y:" + mycoords[1] '''Result:''' .01:08:42 x:746 y:34 .01:08:43 Script stopped = substr = '''Usage:''' Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len. '''Example:''' . '''Result:''' . = substring = '''Usage:''' Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1. '''Example:''' . '''Result:''' . = toLocaleLowerCase = '''Usage:''' Returns a copy of this string, with all uppercase characters converted to lowercase. '''Example:''' . '''Result:''' . = toLocaleUpperCase = '''Usage:''' Returns a copy of this string, with all lowercase characters converted to uppercase. '''Example:''' . '''Result:''' . = toLowerCase = '''Usage:''' Returns a copy of this string, with all uppercase characters converted to lowercase. '''Example:''' . '''Result:''' . = toUpperCase = '''Usage:''' Returns a copy of this string, with all lowercase characters converted to uppercase. '''Example:''' . '''Result:''' . = valueOf = '''Usage:''' Returns the primitive value of a String instance. '''Example:''' . '''Result:''' . |
The following functions can be used to manipulate and retrieve string details from objects and variables.
These should be written in the following formats:
variable.method(arguments), example - myVar.subStr(3,2) if your variable name was "myVar" and you wanted to use subStr() to find the 2 characters that begin 3 from the left.
object.method(arguments), example - city.coords.split(",") if you wanted to split the coordinates of your city into an array to determine the seperate x and y values using the split() function.
Methods
Method |
Type |
Description |
|
|
|
String |
Returns the character in the position specified by the index parameter. |
||||
Number |
Returns the numeric Unicode character code of the character at the specified index. |
||||
String |
Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string. |
||||
String |
Returns a string comprising the characters represented by the Unicode character codes in the parameters. |
||||
int |
Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string. |
||||
int |
Searches the string from right to left and returns the index of the last occurrence of val found before startIndex. |
||||
int |
Compares the sort order of two or more strings and returns the result of the comparison as an integer. |
||||
Array |
Matches the specifed pattern against the string. |
||||
String |
Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl. |
||||
int |
Searches for the specifed pattern and returns the index of the first matching substring. |
||||
String |
Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character. |
||||
Array |
Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs. |
||||
String |
Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len. |
||||
String |
Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1. |
||||
String |
Returns a copy of this string, with all uppercase characters converted to lowercase. |
||||
String |
Returns a copy of this string, with all lowercase characters converted to uppercase. |
||||
String |
Returns a copy of this string, with all uppercase characters converted to lowercase. |
||||
String |
Returns a copy of this string, with all lowercase characters converted to uppercase. |
||||
String |
Returns the primitive value of a String instance. |
charAt
Usage: charAt(#)
Returns the character in the position specified by the index parameter.
Example:
- // Don't forget almost all internal "counting" starts at 0, not at 1...
// so the 5th character would actually be 0, 1, 2, 3, 4 <--- 4!
- var="hello"
- echo "The 5th letter in the word hello is: " + var.charAt(4)
Result:
- 00:49:44 The 5th letter in the word hello is: o
- 00:49:45 Script stopped
charCodeAt
Usage: charCodeAt(#)
Returns the numeric Unicode character code of the character at the specified index.
Example:
- var="hello"
- echo "The numeric code of the 5th letter in the word hello is: " + var.charCodeAt(4)
Result:
- 01:04:27 The numeric code of the 5th letter in the word hello is: 111
- 01:04:28 Script stopped
concat
Usage: concat(arg1,arg2,...,argN)
Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string.
Example:
- var="oompa"
- var2="loompa"
- var3="dance"
- echo var.concat(var2," ",var3)
Result:
- 01:06:48 oompaloompa dance
- 01:06:49 Script stopped
fromCharCode
Usage:
Returns a string comprising the characters represented by the Unicode character codes in the parameters.
Example:
Result:
indexOf
Usage:
Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string.
Example:
Result:
lastIndexOf
Usage:
Searches the string from right to left and returns the index of the last occurrence of val found before startIndex.
Example:
Result:
localeCompare
Usage:
Compares the sort order of two or more strings and returns the result of the comparison as an integer.
Example:
Result:
match
Usage:
Matches the specifed pattern against the string.
Example:
Result:
replace
Usage:
Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl.
Example:
Result:
search
Usage:
Searches for the specifed pattern and returns the index of the first matching substring.
Example:
Result:
slice
Usage:
Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character.
Example:
Result:
split
Usage:
Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs.
Example:
- mycoords=city.coords.split(",")
- echo "x:" + mycoords[0] + " y:" + mycoords[1]
Result:
- 01:08:42 x:746 y:34
- 01:08:43 Script stopped
substr
Usage:
Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len.
Example:
Result:
substring
Usage:
Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1.
Example:
Result:
toLocaleLowerCase
Usage:
Returns a copy of this string, with all uppercase characters converted to lowercase.
Example:
Result:
toLocaleUpperCase
Usage:
Returns a copy of this string, with all lowercase characters converted to uppercase.
Example:
Result:
toLowerCase
Usage:
Returns a copy of this string, with all uppercase characters converted to lowercase.
Example:
Result:
toUpperCase
Usage:
Returns a copy of this string, with all lowercase characters converted to uppercase.
Example:
Result:
valueOf
Usage:
Returns the primitive value of a String instance.
Example:
Result: