Name

RegExp — regular expressions for pattern matching

Availability

Core JavaScript 1.2

Constructor

new RegExp(pattern, 
                     attributes)

Instance Properties

global

Whether a regular expression matches globally. Not implemented in Internet Explorer 4.

ignoreCase

Whether a regular expression is case-insensitive. Not implemented in Internet Explorer 4.

lastIndex

The character position after the last match. Not implemented in Internet Explorer 4.

source

The text of the regular expression.

Static Properties

RegExp.$n

The text that matched the nth subexpression.

RegExp.input or RegExp.$_

The input buffer for pattern matching. Nonfunctional in Internet Explorer 4.

RegExp.lastMatch or RegExp["$&"]

The text of the last successful pattern match. Not implemented in Internet Explorer 4.

RegExp.lastParen or RegExp["$+"]

The text that matched the last subexpression. Not implemented in Internet Explorer 4.

RegExp.leftContext or RegExp["$`"]

The text before the last match. Not implemented in Internet Explorer 4.

RegExp.multiline or RegExp["$*"]

Whether matches are performed in multiline mode. Not implemented in Internet Explorer 4.

RegExp.rightContext or RegExp["$'"]

The text after the last match. Not implemented in Internet Explorer 4.

Methods

compile(newpattern, attributes)

Change a regular expression.

exec(string)

General-purpose pattern matching. Buggy in Internet Explorer 4.

test(string)

Test whether a string contains a match.

Get Webmaster in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.