blob: bdbf885a804f496b8313f2f087deab6a84cf383f [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001/**
2 * Regex object for checking the context of the hint
3 */
4define({
5 create : function (regex) {
6 return Object.create(this)._init(regex);
7 },
8 _init : function (regex) {
9 try {
10 this._regex = new RegExp(regex);
11 }
12 catch (e) {
13 KorAP.log(0, e);
14 return;
15 };
16 return this;
17 },
18 test : function (text) {
19 if (!this._regex.exec(text))
20 return;
21 return RegExp.$1;
22 }
23});