Bring back the Rhino regex patch to use native Java regex.

This commit is contained in:
Tom Robinson
2009-05-30 13:33:54 -07:00
committed by Francisco Ryan Tolmasky I
parent 90e7508700
commit 380b0d0e5d
2 changed files with 7 additions and 8 deletions
+2
View File
@@ -1,6 +1,8 @@
var File = require("file");
var window = require("browser/window");
require("./regexp-rhino-patch");
var exported = ["OBJJ_HOME", "objj_preprocess",
"FRAGMENT_FILE", "FRAGMENT_LOCAL",
"MARKER_CODE", "MARKER_IMPORT_STD", "MARKER_IMPORT_LOCAL",
@@ -1,9 +1,3 @@
importClass(java.util.ArrayList);
importClass(java.util.List);
importClass(java.util.regex.Matcher);
importClass(java.util.regex.Pattern);
importClass(java.util.regex.PatternSyntaxException);
var CachedRegexData = [];
function regexDataFromRegex(aRegex)
@@ -37,10 +31,10 @@ function regexDataFromRegex(aRegex)
source = source.replace("(?<!\\\\)\\{(?!\\d)", "\\\\{", "g");
source = source.replace("(?<!(\\d,?|\\\\))\\}", "\\\\}", "g");
return CachedRegexData[string] = { pattern:Pattern.compile(source, 0), flags:flags };
return CachedRegexData[string] = { pattern:java.util.regex.Pattern.compile(source, 0), flags:flags };
}
String.prototype.match = function(regex)
function newMatch(regex)
{
var regexData = regexDataFromRegex(regex);
@@ -74,3 +68,6 @@ String.prototype.match = function(regex)
return groups;
}
if (system.platform === "rhino")
String.prototype.match = newMatch;