UNPKG

buffer-apg-js

Version:

JavaScript APG, an ABNF Parser Generator

54 lines (53 loc) 1.42 kB
<!DOCTYPE html> <html lang="en"> <head> <title>apg-exp</title> <meta charset="utf-8"> <link rel="stylesheet" href="./css/BrightSide.css" type="text/css" /> <script type="text/javascript" src="./import.js"></script> </head> <body> <div id="wrap"> <div id="header"></div> <div id="content-wrap"> <img src="./images/PointLobosCropped.jpg" width="820" height="120" alt="headerphoto" class="no-border" /> <div id="sidebar"></div> <div id="main-2col"> <!-- page content goes here --> <h1>Property: lastIndex</h1> <h3>Syntax</h3> <pre> var exp = new apgExp(pattern); var n; /* integer > 0 */ exp.lastIndex = n; </pre> <p> Regardless of the matching mode, the pattern match attempt is made starting at index, <kbd>exp.lastIndex</kbd>. The user can set <kbd>exp.lastIndex</kbd> to any value prior to the match attempt. The value of <kbd>exp.lastIndex</kbd> after the match attempt is <a href="./flags.html">mode</a> and result dependent. </p> <h3>Example</h3> <p> <pre> var pattern, str, exp, result; pattern = 'pattern = "abc"\n'; exp = new apgExp(pattern); exp.lastIndex = 6; str = "---abc---ABC---"; result = exp.exec(str); if(result){ console.log("found: " + result[0] + " :at: " + result.index); }else{ console.log("result: null"); } /* returns */ found: ABC :at: 9 </pre> </div> </div> <div id="footer"></div> </div> </body> </html>