Method: test()
The test() method executes a search for a match in the specified string. It operates like the exec() method in most regards, including modes, but operates with less overhead.
Syntax
var exp = new apgExp(pattern[, flags]); var result = exp.test(str);
Parameters
- str: string/array: The string to search for a pattern match in. May be a string or array of integer character codes.
Return
If a match is found, true is returned, otherwise false .
Example
var pattern, str, exp, result; pattern = 'pattern = "abc"\n'; exp = new apgExp(pattern); result = exp.test("---abc"); console.log("result: " + result); result = exp.test([45, 45, 45, 97, 98, 99]); console.log("result: " + result); result = exp.test("xyz"); console.log("result: " + result); /* returns */ result: true result: true result: false