Mega Code Archive

 
Categories / JavaScript Tutorial / Regular Expressions
 

RegExp $& (2)

The RegExp.$& property represents the last matched characters. This is the same as using the lastMatch property. <html>     <body>     <script language="JavaScript">     <!--     var pat = new RegExp("test", "gi");     str = "This is a test 123435";     myArray = pat.exec(str);     document.write("Pattern found: " + myArray[0] + ". the last match expression is: " + RegExp.lastMatch);     -->     </script>     </body>     </html>