Property: Source
The apgExp object retains a copy of the input pattern in the source property.
Syntax
var exp = new apgExp(pattern);
Parameters
exp.source: Copy of pattern.
exp.sourceToText(): Returns source as text.
exp.sourceToHtml(): Returns source as HTML.
exp.sourceToHtmlPage(): Returns source as HTML, wrapped in a header and body for to make a complete HTML page..
Example 1
var pattern, exp; pattern = 'word = alpha *(alpha / num)\n'; pattern += 'alpha = %d65-90 / %d97-122\n'; pattern += 'num = %d48-57\n'; exp = new apgExp(pattern); console.log("source:"); console.log(exp.source); / * result */ source: word = alpha *(alpha / num) alpha = %d65-90 / %d97-122 num = %d48-57
Example 2
The sourceToText() function returns the pattern. It simply returns exp.source and is mostly for symmetry in the output functions./* same as Example 1 */ console.log("source:"); console.log(exp.sourceToText()); / * result */ source: word = alpha *(alpha / num) alpha = %d65-90 / %d97-122 num = %d48-57
Example 3
exp.sourceToHtml() returns the pattern formatted as HTML. HTML characters, such as "<" and control characters are converted to entities and special display formats. The display page header should include the apgexp.css style sheet. e.g.<link rel="stylesheet" href="./apg-js/dist/apg-lib-bundle.css" type="text/css" />exp.sourceToHtml() returns the same, except wrapped in a complete page header and body.
/* same as Example 1 */ $("#this-page").html(exp.sourceToHtml()); / * result */ word = alpha *(alpha / num)LF alpha = %d65-90 / %d97-122LF num = %d48-57LF