headerphoto

Unicode Mode

Syntax

var exp    = new apgExp(pattern, "u");

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 result object values are arrays of integer character codes rather than strings.

Example

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 ]