Index: compiled/library.js |
=================================================================== |
--- a/compiled/library.js |
+++ b/compiled/library.js |
@@ -56,22 +56,25 @@ |
FilterNotifier.triggerListeners(notifierTopics.get(topic), |
exports.Subscription.fromPointer(subscription)); |
}, |
$_regexp_data: Object.create(null), |
$_regexp_counter: 0, |
GenerateRegExp__deps: ["$_regexp_data", "$_regexp_counter"], |
- GenerateRegExp: function(source, matchCase) |
+ GenerateRegExp: function(source, matchCase, global) |
{ |
var id = ++_regexp_counter; |
try |
{ |
- _regexp_data[id] = new RegExp(readString(source), matchCase ? "" : "i"); |
+ var flag = matchCase ? "" : "i"; |
+ if (global) |
+ flag += "g"; |
+ _regexp_data[id] = new RegExp(readString(source), flag); |
return id; |
} |
catch (e) |
{ |
return -1; |
} |
}, |
@@ -80,10 +83,32 @@ |
{ |
delete _regexp_data[id]; |
}, |
TestRegExp__deps: ["$_regexp_data"], |
TestRegExp: function(id, str) |
{ |
return _regexp_data[id].test(readString(str)); |
+ }, |
+ |
+ ExecRegExp__deps: ["$_regexp_data"], |
+ ExecRegExp: function(id, str) |
+ { |
+ var match = _regexp_data[id].exec(readString(str)); |
+ if (match) |
+ return match.index; |
+ return -1; |
+ }, |
+ |
+ MatchRegExp__deps: ["$_regexp_data"], |
+ MatchRegExp: function(id, str, reMatchResults) |
+ { |
+ var string = readString(str); |
+ var result = new exports.ReMatchResults(reMatchResults); |
+ var matches = string.match(_regexp_data[id]); |
+ if (!matches) |
+ return false; |
+ for (var i = 0; i < matches.length; i++) |
+ result.push(createString(matches[i])); |
+ return true; |
} |
}); |