next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: onContextMenu   Contents

RegExp Object

Description

Contains a regular expression pattern used when searching strings for character combinations.

available: SWFKit Express, SWFKit, SWFKit Pro

Syntax

  1. /pattern/[switch]
  2. new RegExp(pattern, [switch])


Parameters

pattern
The regular expression pattern to use
switch
Optional. Available switches are:
i
ignore case
g
global search for all occurrences of pattern
m
multiline
gi
global search, ignore case


Example

r = /ab+/gi;
s = "abbdabbcabdaBa";
trace(r.exec(s));//output: abb
re = new RegExp("d(b+)(d)","ig");
str = "cdbBdbsbdbdz";
trace(re.exec(str));//output: dbBd,bB,d


Remarks

The following table describes the subexpression meanings of a regular expression when used for pattern matching:

Subexpression   Matched Text
literal character   Any source character which is a ReLiteralCharacter.
.   Any character except newline.
^   Start of string. The matched substring must begin with the the first character of the string (after the portion ignored as specified by lastIndex). This character is only special when it appears as the first character of the regular expression.
$   End of string. The matched substring must end with the the last character of the string. This character is only special when it appears as the last character of the regular expression.
x*   Zero or more consecutive matches with subexpression x. The matched substrings need not be identical.
x+   One or more consecutive matches with subexpression x. The matched substrings need not be identical.
x?   Zero or one consecutive matches with subexpression x.
X{n}   Exactly n consecutive matches with subexpression x.
X{n,}   At least n consecutive matches with subexpression x.
X{m,n}   At least m and at most n consecutive matches with subexpression x.
X{n}   Exactly n consecutive matches with subexpression x.
(x)   The same pattern as subexpression x. The matched substring is available for use in a subsequent "\n" pattern.
xy   The subexpression x followed by the subexpression y.
x|y   Either of the subexpressions x or y.
[pqr]   Any character in pqr, which is a sequence of one or more source characters and/or subranges of the form s-t. If the Unicode encoding of s is greater than the Unicode encoding of t, a runtime error is generated. Only the characters ^, -, ] and need to be escaped when intended as literal characters. The "^" character need be escaped only if it is the first character in pqr. The "-" character need not be escaped if it is the first or last character, or if it immediately follows a subrange. The escape sequences have their usual meanings except for "\b" which matches the backspace character; "\B" which matches "B"; and, for subranges only, "\d", "\D", "\s", "\S", "\w" and"\W", which match "d", "D", "s", "S", "w" and "W", respectively.
[pqr]   Any character not matched by "[pqr]", including newline if pqr does not contain newline.
\f   The formfeed character.
\n   The newline character.
\r   The carriage return character.
\t   The tab character.
\v   The vertical tab character.
\s   Any whitespace character; equivalent to "[\f\n\r\t\v]".
\S   Any non-whitespace character; equivalent to "[^\f\n\r\t\v]".
\d   Any decimal digit; equivalent to "[0-9]".
\D   Any character except a decimal digit; equivalent to "[^0-9]".
\w   Any character valid in an identifier; equivalent to "[a-zA-Z0-9_]".
\W   Any character not valid in an identifier; equivalent to "[a-zA-Z0-9_]".
\b   Word boundary: a zero-length substring which is bounded on one side by a character which matches "\w" and on the other side by a character which matches "\W" or the start of the string or the end of the string.
\B   Non-word boundary: a zero-length substring which does not match "\b".
\cX   The character formed by an exclusive OR of the character code with 64.
\n   Either an OctalEscapeSequence or a backreference equivalent to the exact substring most recently matched by the nth parenthesized subexpression, as determined by the opening left parenthesis of each such subexpression. If n begins with 0, or if the value of n (when parsed and converted as DecimalDigits) is greater than 9 and also greater than the number of parenthesized subexpressions, then \n is an OctalEscapeSequence; otherwise \n is a backreference. If there is no corresponding parenthesized subexpression, or if the subexpression does not participate in the match (because of the "\" operator or a zero count), \n is treated as the empty string.
 
 
If the ignoreCase property is true (this property is set by the switch parameter of the constructor) when a pattern match is performed, any letters in the string are matched without considering distinctions between uppercase and lowercase.

An empty pattern matches the start of any string including the empty string.

The match and search method of String object modify the properties of RegExp just like the exec method of RegExp Object.




Subsections
next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: onContextMenu   Contents
Copyright ©2000-2007 Shanghai TopCMM Software Technologies. All Rights Reserved.