RegExp |
Core JavaScript 1.2; JScript 3.0; ECMA v3 |
regular expressions for pattern matching |
|
Literal Syntax
/pattern/attributes
Constructor
new RegExp(pattern, attributes)
Regular expression patterns are expressed using a complex grammar
that is summarized earlier in this book.
Instance Properties
- global
-
A read-only boolean that specifies whether the RegExp has the
g attribute and therefore performs global
matching.
- ignoreCase
-
A read-only boolean that specifies whether the RegExp has the
i attribute and therefore performs
case-insensitive matching.
- lastIndex
-
For global RegExp objects, this read/write property specifies the
character position immediately following the last match; this is the
first character examined for the next match.
- multiline
-
A read-only boolean that specifies whether the RegExp has the
m attribute and therefore performs multi-line
matching.
- source
-
A read-only string that holds the source text of the regular
expression pattern, excluding slashes and
attributes.
Methods
- exec( string)
-
Matches string against this RegExp and
returns an array containing the results of the match, or
null if no match was found. Element 0 of the array
is the matching text. Subsequent elements of the array contain the
substrings that matched the subexpressions within the RegExp. The
returned array also has an index property that
specifies the start position of the match.
- test( string)
-
Returns true if string
contains text matching this RegExp, or false
otherwise.
See Also
String.match( ), String.replace(
), String.search( )
|