RegExp Class Reference
[ECMAScript/QtScript - Native Objects]

ECMAScript RegExp type. More...

Inheritance diagram for RegExp:

Object List of all members.

Properties (DAZ Script 2 Extensions)

Array capturedTexts
Boolean empty
Number matchedLength
Boolean valid

Properties (ECMAScript)

Boolean global
Boolean ignoreCase
Number lastIndex
Boolean multiline
String source

Methods (DAZ Script 2 Extensions)

String cap (Number which)
Boolean exactMatch (String text)
Number pos (Number which)
Number search (String text)
Number searchRev (String text)

Methods (ECMAScript)

Array exec (String string)
Boolean test (String string)
String toString ()

Constructors

 RegExp (String expression)

Detailed Description

ECMAScript RegExp type.

This is the DAZ Script counterpart of the QRegExp type used in the DAZ Studio SDK.

A RegExp object is a regular expression. Regular expressions are patterns used to perform searches in, or replace text in, strings.

Regular expressions can be created in DAZ Script directly, or via the constructor. The following example shows creating expressions via the two methods, both of which result in identical expressions.

Recommended Reading:

Example:
    var regexp1 = /([A-Z]+)=(\d+)/;
    var regexp2 = new RegExp( "([A-Z]+)=(\\d+)" );


Constructor & Destructor Documentation

RegExp::RegExp ( String  expression  ) 

Default constructor.

Parameters:
expression - The string representing the expression syntax.
Attention:
All backslashes in expression must be escaped with an additional backslash.


Member Function Documentation

String RegExp::cap ( Number  which  ) 

Parameters:
which The index of the capture to return
Returns:
The capture at the given index of the pattern in the previously matched text.

Boolean RegExp::exactMatch ( String  text  ) 

Parameters:
text - The String to search with the expression pattern.
Returns:
True if text exactly matches this expression's pattern, otherwise false.

Array RegExp::exec ( String  string  ) 

Performs a regular expression match on the given string.

Returns:
An array of results for the match, or undefined if no matches were found.

Number RegExp::pos ( Number  which  ) 

Parameters:
which The index of the capture to return
Returns:
The position of the capture at the given index of the pattern in the previously matched text.

Number RegExp::search ( String  text  ) 

Parameters:
text - The String to search with the expression pattern.
Returns:
The [zero-based] index of the first occurrence of this expression's pattern in text, starting at the beginning of text. If no match is made -1 is returned.

Number RegExp::searchRev ( String  text  ) 

Parameters:
text - The String to search with the expression pattern.
Returns:
The [zero-based] index of the first occurrence of this expression's pattern in text, starting at the end of text. If no match is made -1 is returned.

Boolean RegExp::test ( String  string  ) 

Performs a regular expression match on the given string.

Returns:
true if one or more matches was found, otherwise false.

String RegExp::toString (  ) 

Returns:
The regular expression pattern as a String.

Reimplemented from Object.


Member Data Documentation

Array RegExp::capturedTexts

Provides an array of all the captured strings from the previous match. undefined if there was no match. (Read Only)

Boolean RegExp::empty

True if the expression is empty, otherwise false. (Read Only)

Boolean RegExp::global

Used to indicate that the RegExp should be matched globally. A global RegExp will match every occurrence (as many times as possible), whereas a non-global RegExp will match only once at most (the first match it encounters). This is particularly relevant for String::replace() where every occurrence of a pattern will be replaced when global is true.

Boolean RegExp::ignoreCase

Read Only. Used to indicate that the RegExp ignores case when matching. This is true when the pattern flags contain the character "i".

Number RegExp::lastIndex

The string position at which to start the next match.

Number RegExp::matchedLength

Holds the length of the last matched string. -1 if there was no match. (Read Only)

Boolean RegExp::multiline

Read Only. Used to indicate that the RegExp matches across multiple lines. This is true when the pattern flags contain the character "m".

String RegExp::source

A string value representing the pattern source.

Boolean RegExp::valid

True if the expression is syntactically valid, otherwise false. (Read Only)


Generated on Thu Sep 24 12:21:16 2009

Copyright © 2002 - 2009 DAZ 3D, Inc.