UNPKG

buffer-apg-js

Version:

JavaScript APG, an ABNF Parser Generator

52 lines (51 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>Unicode Mode</h1> <h3>Syntax</h3> <pre> var exp = new apgExp(pattern, "u"); </pre> <p> The pattern match attempt is made according to the default mode or, if the global or sticky flag is set, according to that mode, respectively. If a match is found, the returned <kbd><a href="./result.html">result</a></kbd> object values are arrays of integer character codes rather than strings. </p> <h3>Example</h3> <p> <pre> var pattern, str, exp, result; pattern = 'word = alpha *(alpha / num)\n'; pattern += 'alpha = %d65-90 / %d97-122\n'; pattern += 'num = %d48-57\n'; exp = new apgExp(pattern, "u"); str = "ab12"; result = exp.exec(str); console.log(result[0]); console.log(result.rules.alpha[0].phrase); console.log(result.rules.num[0].phrase); /* returns */ [ 97, 98, 49, 50 ] [ 97 ] [ 49 ] </pre> </div> </div> <div id="footer"></div> </div> </body> </html>