vexi.js.String - String Object

Strings can be created as literals in javascript using "" or ''

Properties

Property Type Description

length

Number

The number of characters in a string.

Methods

Method Returns Description

charAt(pos)

String

Returns the character at position pos in the string.

If pos is omitted, it defaults to 0. If pos is outside the range of valid characters, the function returns "".

charCodeAt(pos)

Number

Returns the numeric value of the character at position pos in the string.

If pos is omitted, it defaults to 0. If pos is outside the range of valid characters, the function returns NaN.

compareTo(str)

Number

Compares two strings lexicographically. Returns -1,0,1 depending on whether the string precedes, is equal to, or follows str

concat(str1, ...strn)

String

Constructs a new string which is a concatenation of the current string and all values passed to the function.

indexOf(search, start)

Number

Returns the first position of sub-string search in the current string, with search starting at position start. If the sub-string is not found, the function returns -1.

If start is omitted, it defaults to the start of the string; if search is omitted, then it defaults to null.

lastIndexOf(search, end)

Number

Returns the last position of sub-string search in the current string, but will only search up to position end. If the sub-string is not found, the function returns -1.

If end is omitted, it defaults to the length of the string; if search is omitted, then it defaults to null.

match(regexp)

String

Returns expression.stringMatch(string) — see regexp.stringMatch(string).

replace(regexp, str)

String

Returns expression.stringReplace(string, replaceString) — see regexp.stringReplace(searchString, replaceString).

search(regexp)

String

Returns expression.stringSearch(string) — see regexp.stringSearch(string).

slice(start[, end])

String

Returns the section of the string between start and end — 1, inclusive.

If either argument is less than 0, then the argument is treated as the number of characters counted backwards from the end of the string. If start is omitted, it defaults to the start of the string; if end is omitted, it defaults to the string’s length. If start is greater than end, the function returns "".

split(regexp[, limit])

Array

Splits the current string into separate strings, using the sub-string defined by expression as a separator. Returns an array of limit elements that contains the list of strings.

substr(start[, length])

String

Returns the section of the string beginning at start and continuing for length characters.

If length is omitted, then the remaining length of the string is used. If both start and length are omitted, then the entire string is returned.

substring(start[, end])

String

Returns the section of the string between start and end — 1, inclusive.

If end is omitted, it defaults to the string’s length. If both start and end are omitted, then the entire string is returned. If start is greater than end, the two values are swapped.

toLowerCase()

String

Returns the lower-case equivalent of the current string

toString()

String

Returns the current string.

toUpperCase()

String

Returns the upper-case equivalent of the current string

trim()

String

Returns the string with leading and trailing whitespace removed

 


Copyright © 2011 The Vexi Project (vexi.sourceforge.net)