Data Types - Strings


Special characters in string

Character Description
\n new line
\t tab
\r carriage return
\f form feed
\b backspace

Operators

Properties

Property Description
length An integer value containing the length of the string expressed as the number of characters in the string.

Methods (built-in functions)

Method Description
anchor(name) Returns a string containing the value of the string object surrounded by an A container tag with the NAME attribute set to name.
big() Return a string containing the value of the string object surrounded by a BIG container tag.
blink() Returns a string containing the value of the string object surrounded by a BLINK container tag.
bold() Returns a string containing the value of the string object surrounded by a B container tag.
charAt(index) Returns the character at the location specified by index.
charCodeAt(index) Returns the ascii code of the character at the location specified by index.
concat(string) Combines the text of two strings and returns a new string.
fixed() Returns a string containing the value of the string object surrounded by a FIXED container tag.
fontcolor(colour) Returns a string containing the value of the string object surrounded by a FONT container tag with the COLOR attribute set to color where color is a color name or RGB triplet.
fontsize(size) Returns a string containing the value of the string object surrounded by a FONTSIZE container tag with the size set to size.
indexOf(findString,startIndex) Returns the index of the first occurrence of findString, starting the search at startingIndex where startingIndex is optional - if it is not provided, the search starts at the start of the string.
italics() Returns a string containing the value of the string object surrounded by an I container tag.
lastIndexOf(findString,startingIndex) Returns the index of the last occurrence of findstring. This is done by seaching backwards from startingIndex. StartingIndex is optional and assumed to be the last charatr nthe tring if no value is provided.
link(href) Return a string containing the value of the string object surrounded by an A container tag with the HREF attribute set to href.
match(regexp) Returns TRUE if the string matches the regular expression, FALSE otherwise.
replace(regexp, newSubStr) Returns a new string, where the substring represented by the regular expression is replaced by the newSubStr.
search(regexp) Returns the index of the start of the string represented by the regular expression. If no string matching the reqular expression is found then -1 is returned.
slice(beginslice,endslice) Returns a new string, which is the substring of the string starting at the character specified by the beginslice and ending at the character specified by the endslice. If the endslice is omitted, then the substring returned starts at the beginslice character and goes to the end of the string.
small() Returns a string containg in the value of the string object surrounded by a SMALL container tag.
split(separator, limit) Breaks the string into substrings based on the separator charactor provided.What is returned is an array of strings. The limit paramater is option and specifies a limit to how many substrings are created.
strike() Returns a string containing the value of the string object surrounded by a STRIKE container tag.
sub() Returns a string containing the value o the string object surrounded by a SUB container tag.
substr(start, length) Returns the substring starting at the character specified by the start indexfor length number of charactes. If the length is omitted, then the substring starts at the character specified by the start index and goes to the end of the string.
substring(firstIndex,lastIndex) Returns a string equivalent to the substring starting at firstIndex and ending at the character before lastIndex. If firstIndex is greater than lastIndex, the string starts at lastIndex and ends at the character before firstIndex.
sup() Returns a string containing the value of the strin ojct surounded by a SUP container tag.
toLowerCase() Returns a string containing the value f the string object with all characters converted to lower case.
toUpperCase() Returns a string containing the value of the string object with all characters converted to upper case.

For more details and examples look at http://developer.netscape.com/docs/manuals/communicator/jsref/corea2.htm

NOTE: concat, match, replace, search, slice, and substr are only supported in JavaScript 1.2 and above. This the browser level must be at least 4.0 for bothe Netscape and Explorer.

Back