460 Working with Text and Strings
About the escape character
You can use the backslash escape character (\), to define other characters in string literals.
For more information on string literals, see Chapter 5, “About literals,” on page 130 and
“Creating strings” on page 458.
Analyzing and comparing characters in strings
Every character in a string has an index position in the string (an integer). The index position
of the first character is 0. For example, in the string
yellow, the character y is in position 0
and the character
w is in position 5.
Every string has a length property, which is equal to the number of characters in the string:
var companyStr:String = "macromedia";
trace(companyStr.length); // 10
An empty string and a null string both have a length of zero:
var firstStr:String = new String();
trace(firstStr.length); // 0
var secondStr:String = "";
trace(secondStr.length); // 0
Escape sequence Description
\b
The backspace character.
\f
The form feed character.
\n
The newline character.
\r
The carriage return.
\t
The tab character.
\unnnn
The Unicode character with the character code specified by the
hexidecimal number
nnnn. For example, \u263a is the smile
character.
\xnn
The ASCII character with the character code specified by the
hexidecimal number
nn.
\'
A single quotation mark.
\"
A double quotation mark.
\\
A single backslash character.