This is the script counterpart to the QRegExp type used in the C++ 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 DAZScript 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 regxPair1 = /([A-Z]+)=(\d+)/; var regxPair2 = new RegExp( "([A-Z]+)=(\\d+)" );
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
. This is true
when the pattern flags contain the character “g”.
Used to indicate that the RegExp ignores case when matching. This is true
when the pattern flags contain the character “i”. (Read Only)
The string position at which to start the next match.
Used to indicate that the RegExp matches across multiple lines. This is true
when the pattern flags contain the character “m”. (Read Only)
A string value representing the pattern source.
Provides an array of all the captured strings from the previous match. undefined
if there was no match. (Read Only)
true
if the expression is empty, otherwise false
. (Read Only)
Holds the length of the last matched string. -1
if there was no match. (Read Only)
true
if the expression is syntactically valid, otherwise false
. (Read Only)
RegExp( String expression, String flags=“” )
Default constructor.
Parameter(s):
global
), “i” (ignoreCase
), or “m” (multiline
), or a combination thereof, used to modify how the expression is applied.Attention:
expression
must be escaped with an additional backslash.Performs a regular expression match on the given string.
Return Value:
Boolean : test( String string )
Performs a regular expression match on the given string.
Return Value:
true
if one or more matches was found, otherwise false
.Return Value:
Parameter(s):
Return Value:
Boolean : exactMatch( String text )
Parameter(s):
Return Value:
true
if text
exactly matches this expression's pattern, otherwise false
.Parameter(s):
Return Value:
Number : search( String text )
Parameter(s):
Return Value:
text
, starting at the beginning of text
. If no match is made -1
is returned.Number : searchRev( String text )
Parameter(s):
Return Value:
text
, starting at the end of text
. If no match is made -1
is returned.