RegExp.$&
JavaScript 1.2+, Jscript 3.0+ Nav4+, NES3+, IE4+ Syntax
RegExp.$&
Description
The RegExp.$& property represents the last matched characters. This is the same as using the lastMatch property.
Example
Listing 6.208 shows how RegExp.$& is used.
Listing 6.208 Example of RegExp.$&
<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.