RegExp.lastMatch

JavaScript 1.2+, JScript 3.0+ Nav4+, NES3+, IE4+ Syntax

							regexp.lastMatch

Description

The lastMatch property of the RegExp object represents the last matched characters.

Example

Listing 6.220 shows how the lastMatch property is used.

Listing 6.220 Example of lastMatch Property
<html>
<body>

<script language="JavaScript">
<!–– Hide
// define a pattern to search for
var pat = new RegExp("test", "gi");
str = "Testing Testing 123";
myArray = pat.exec(str);

// Once pattern is found, display message.
document.write("Pattern found: " + myArray[0] +
             ". the last match expression is: " + RegExp.lastMatch);
// End Hide ––>
</script>

</body>
</html>
							
							
						

Get Pure JavaScript 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.