String |
Core JavaScript 1.0; JScript 1.0; ECMA v1 |
string manipulation |
Inherits From: Object |
Constructor
String(s)
new String(s)
Without the new operator, the String(
) function converts its argument to a string. With the
new operator, it is a constructor that wraps the
converted value in a String object.
Properties
- length
-
The number of characters in the string. Read-only.
Methods
- charAt( n)
-
Returns the character at position n in the
string.
- charCodeAt( n)
-
Returns the Unicode encoding of the character at position
n in the string. JS 1.2; JScript 5.5; ECMA
v1.
- concat( value, ...)
-
Returns a new string that results from converting each of the
arguments to a string and concatenating the resulting strings. JS
1.2; JScript 3.0; ECMA v3.
- indexOf( substring, start)
-
Returns the position of the first occurrence of
substring within this string that appears
at or after the start position or -1 if no
such occurrence is found. If start is
omitted, 0 is used.
- lastIndexOf( substring, start)
-
Returns the position of the last occurrence of
substring within
string that appears before the
start position, or -1 if no such
occurrence is found. If start is omitted, the
string length is used.
- match( regexp)
-
Matches this string against the specified regular expression and
returns an array containing the match results or
null if no match is found. If
regexp is not a global regular expression,
the returned array is the same as for the RegExp.exec(
) method. If regexp is global
(has the "g" attribute), the
elements of the returned array contain the text of each match found.
JS 1.2; JScript 3.0; ECMA v3.
- replace( regexp, replacement)
-
Returns a new string, with text matching
regexp replaced with
replacement.
regexp may be a regular expression or a
plain string. replacement may be a string,
containing optional regular expression escape sequences (such as
$1) that are replaced with portions of the matched
text. It may also be a function that computes the replacement string
based on match details passed as arguments. JS 1.2; JScript 3.0; ECMA
v3.
- search( regexp)
-
Returns the position of the start of the first substring of this
string that matches regexp, or -1 if no
match was found. JS 1.2; JScript 3.0; ECMA v3.
- slice( start, end)
-
Returns a new string that contains all the characters of
string from and including the position
start and up to but not including
end. If end is
omitted, the slice extends to the end of the string. Negative
arguments specify character positions measured from the end of the
string. JS 1.2; JScript 3.0; ECMA v3.
- split( delimiter, limit)
-
Returns an array of strings, created by splitting
string into substrings at the boundaries
specified by delimiter.
delimiter may be a string or a RegExp. If
delimiter is a RegExp with a parenthesized
subexpression, the delimiter text that matches the subexpression is
included in the returned array. See also Array.join(
). JS 1.1; JScript 3.0; ECMA v1.
- substring( from, to)
-
Returns a new string that contains characters copied from positions
from to to-1 of
string. If to is
omitted, the substring extends to the end of the string. Negative
arguments are not allowed.
- substr( start, length)
-
Returns a copy of the portion of this string starting at
start and continuing for
length characters, or to the end of the
string, if length is not specified. JS
1.2; JScript 3.0; Non-standard: use slice( ) or
substring( ) instead.
- toLowerCase( )
-
Returns a copy of the string, with all uppercase letters converted to
their lowercase equivalent, if they have one.
- toUpperCase( )
-
Returns a copy of the string, with all lowercase letters converted to
their uppercase equivalent, if they have one.
Static Functions
- String.fromCharCode( c1, c2, ...)
-
Returns a new string containing characters with the encodings
specified by the numeric arguments. JS 1.2; JScript 3.0; ECMA v1.
|