| Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 1 | /** |
| 2 | * Regex object for checking the context of the hint | ||||
| 3 | */ | ||||
| 4 | define({ | ||||
| 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 | }); | ||||