This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

lastMatch

Summary

Returns the last matched characters from any regular expression search. Read-only.

Syntax

RegExp.lastMatch

Examples

The following example illustrates the use of the lastMatch property:

// Create the regular expression pattern.
    var re = new RegExp("d(b+)(d)","ig");
    var str = "cdbBdbsbdbdz";

    // Perform the search.
    var arr = re.exec(str);

    // Print the output.
    var s = ""
    s += ": " + RegExp. + "<br />";
    s += ": " + RegExp. + "<br />";
    s += ": " + RegExp. + "<br />";
    s += "input: " + RegExp.input + "<br />";
    s += "lastMatch: " + RegExp.lastMatch + "<br />";
    s += "leftContext: " + RegExp.leftContext + "<br />";
    s += "rightContext: " + RegExp.rightContext + "<br />";
    s += "lastParen: " + RegExp.lastParen + "<br />";

    document.write(s);

Remarks

The object associated with this property is always the global RegExp object.

The initial value of the lastMatch property is an empty string. The value of the lastMatch property changes whenever a successful match is made.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article