JS-STRING
Arcane Ages includes the following standard JavaScript String properties:
length The length of the string.
and methods:
charAt( pos ) | Returns the character at the specified position. "foobar".charAt( 0 ) == 'f', "big".charAt( 2 ) == 'g' |
concat( s1, ... ) | Returns a new string which is the concatenation of the current strings and all the strings passed into this method. ex: "1".concat("2","foo","cat") returns "12foocat" |
indexOf( s, p ) | Returns the character index of the first occurrence of string "s" starting at position "p". "p" is optional, if it is not present, it is set to 0 by default. If the string isn't present, -1 is returned. "foobarbar".indexOf( "bar", 4 ) returns 6. "barfoobar".indexOf( "bar" ) returns 0. |
lastIndexOf( s, p ) | Returns the character index of the last occurrence of string "s" starting at position "p". "p" is optional, if it is not present, it is set to length-1 by default. If the string isn't present, -1 isn't returned. "barfoobar".lastIndexOf( "bar" ) returns 6. |
split( del, lim ) | Returns an Array of strings by splitting up the string into words separated by the given delimiter. "good day friend".split(' ') returns "good","day","friend" "2,4,2,1".split(",") returns "2", "4", "2", "1". If The optional limit is specified only a maximum of "lim" entries will be made. ex: "2,3".split(",",1) returns "2" |
slice( s, e ) | Returns a substring created by taking the characters starting at character "s" and ending at character "e". If "e" is not provided, it defaults to len. Either option may be negative. If it is negative, it is treated as if it counts from the end of the string, rather than the beginning. "foobar".substring(3) returns "bar". "foobar".substring(1,3) returns "oo". "foobar".substring(0,-3) returns "foo". |
substring( s, e ) | This functions similarly to "slice()" but does not support negative indices. |
toLowerCase() | Returns a lowercase version of the string. "This IS Now".toLowerCase() returns "this is now". |
toUpperCase() | Returns an uppercase version of the string. "This IS Now".toUpperCase() returns "THIS IS NOW". |
Arcane Ages also implements the HTML tag generation methods of the String object but since those aren't that useful for Arcane Ages they aren't documented here. Arcane Ages also implements the following additional methods:
md5() | These returns a base64-encoded MD5 hash for this string. This can be used to encode the answer to a riddle to hide answers from "curious" immortals. See MD5 for more information. |
plural() | This returns a plural version of the given string. "dress".plural() returns "dresses". |
wordAt( p ) | Returns the word at position "p". "this is a nice day".wordAt( 3 ) returns "nice". |
isWordAbbrev( p, s ) | Returns true if the "p"th word in this string is an abbreviation of the string "s" (case-insensitive). "desc spe".isWordAbbrev( 1, "spells" ) returns true because "spe" is an abbreviation of "spells". |
f() | C printf() style formatting. See JS-STRING-F. |
like( s ) | Compares this string to see if this string is like the string s. See JS-LIKE. |
autoformat() | This returns a new string that has been autoformatted by the mud's autoformatter. |