• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages
    • Diff for "Strings"
    Differences between revisions 13 and 14
    Revision 13 as of 2012-10-28 04:50:30
    Size: 4124
    Editor: Inanna
    Comment:
    Revision 14 as of 2012-10-28 04:59:08
    Size: 4061
    Editor: Inanna
    Comment:
    Deletions are marked like this. Additions are marked like this.
    Line 20: Line 20:
    ||charCodeAt ||Number ||var="hello"<<BR>>echo "The char code for the 5th letter in the word hello is: " + var.charAt(4) ||Returns the numeric Unicode character code of the character at the specified index. In this example, returns "111" which is the numeric code for "o"||
    ||concat ||String ||var="oompa"<<BR>>var2="loompa"<<BR>>var3="dance"<<BR>>echo var.concat(var2," ",var3) ||Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string. In this example, returns "oompaloompa dance".||
    ||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. ||
    ||lastI
    ndexOf ||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 ||mycoords=city.coords.split(",")<<BR>>echo "x:" + mycoords[0] + " y:" + mycoords[1] ||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. ||
    ||[[#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. ||
    Line 40: Line 40:
    '''Usage:'''
    charAt(#)
    '''Usage:''' charAt(#)
    Line 46: Line 45:
     var="hello"
     echo "The 5th letter in the word hello is: " + var.charAt(4)
     .var="hello"
     .echo "The 5th letter in the word hello is: " + var.charAt(4)
    Line 50: Line 49:
     00:49:44 The 5th letter in the word hello is: o
     00:49:45 Script stopped
     .00:49:44 The 5th letter in the word hello is: o
     .00:49:45 Script stopped

    == ==
    '''Usage:'''

    Description

    '''Example:'''
     .

    '''Result:'''
     .

    The following can be used to manipulate and retrieve string details from variables.

    These should be written in the following format: varname.method(arguments), e.g. myVar.subStr(3,2) if your variable name was "myVar" and you wanted to use the subStr function to find the 2 characters that begin 3 from the left.

    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:

    • // 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:
      01:25:34 The 5th letter in the word hello is: o
      01:25:35 Script stopped

    Methods

    Method

    Type

    Description

    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.

    charAt

    Usage: charAt(#)

    Returns the character in the position specified by the index parameter.

    Example:

    • 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

    Usage:

    Description

    Example:

    Result:


    ScriptVariables

    Strings (last edited 2015-02-08 06:30:49 by LKD70)