Mega Code Archive

 
Categories / JavaScript Tutorial / Regular Expressions
 

RegExp $` (4)

The RegExp.$` property represents the substring preceding the most recent pattern match. This is the same as using the leftContext property. <html>     <body>     <script language="JavaScript">     <!--         pat = /is*/g;         var str = "This is a test.";         myArray = pat.exec(str);              document.write("In the string: " + "<b>");         document.write("I know where the fish is tonight" + "</b><br><br>");         document.write("The RegExp.leftContext is: " + RegExp.leftContext);     -->     </script>     </body>     </html>