Finding Substrings And Patterns In Strings - Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual

Programming actionscript 3.0
Table of Contents

Advertisement

str = str + area;
// str == "Area = 28.274333882308138"
However, you can use parentheses for grouping to provide context for the
following example shows:
trace("Total: $" + 4.55 + 1.45);
//"Total: $4.551.45"
trace("Total: $" + (4.55 + 1.45));
//"Total: $6"

Finding substrings and patterns in strings

Substrings are sequential characters within a string. For example, the string
following substrings:
methods to locate substrings of a string.
Patterns are defined in ActionScript by strings or by regular expressions. For example, the
following regular expression defines a specific pattern—the letters A, B, and C followed by a
digit character (the forward slashes are regular expression delimiters):
/ABC\d/
ActionScript includes methods for finding patterns in strings and for replacing found matches
with replacement substrings. These methods are described in the following sections.
Regular expressions can define intricate patterns. For more information, see
"Using Regular Expressions," on page
Finding a substring by character position
The
and
substr()
substring()
Both take two parameters. In both methods, the first parameter is the position of the starting
character in the given string. However, in the
length of the substring to return, and in the
the position of the character at the end of the substring (which is not included in the returned
string). This example shows the difference between these two methods:
var str:String = "Hello from Paris, Texas!!!";
trace(str.substr(11,15)); // Paris, Texas!!!
trace(str.substring(11,15)); // output: Pari
214
Working with Strings
,
,
,
""
"a"
"ab"
"abc"
285.
methods are similar. Both return a substring of a string.
,
,
,
. You can use ActionScript
"b"
"bc"
"c"
method, the second parameter is the
substr()
method, the second parameter is
substring()
operator, as the
+
has the
"abc"
Chapter 10,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents