Skip to content
Snippets Groups Projects
Commit 808d92fc authored by Tomas Stupka's avatar Tomas Stupka
Browse files

do not check predefined classes in grep pattern if it is supposed to be macthed as is (fixed=TRUE)

parent 85c38b63
No related branches found
No related tags found
No related merge requests found
......@@ -793,7 +793,7 @@ public class GrepFunctions {
throw RInternalError.unimplemented("multi-element patterns in regexpr not implemented yet");
}
String pattern = patternArg.getDataAt(0);
if (!perl) {
if (!perl && !fixed) {
pattern = RegExp.checkPreDefinedClasses(pattern);
}
// TODO: useBytes normally depends on the value of the parameter and (if false) on
......@@ -1090,7 +1090,7 @@ public class GrepFunctions {
throw RInternalError.unimplemented("multi-element patterns in gregexpr not implemented yet");
}
String pattern = patternArg.getDataAt(0);
if (!perl) {
if (!perl && !fixed) {
pattern = RegExp.checkPreDefinedClasses(pattern);
}
// TODO: useBytes normally depends on the value of the parameter and (if false) on
......
......@@ -120,5 +120,12 @@ public class TestBuiltin_gregexpr extends TestBase {
assertEval("{ x<-c(\"Aaa bbb Aaa Bbb\", \"Aaa bbb Aaa bbb\", \"Aaa bbb Aaa Bbb\"); p<-\"(?<first>[[:upper:]][[:lower:]]+) (?<last>[[:upper:]][[:lower:]]+)\"; gregexpr(p, x, perl=TRUE) }");
assertEval("{ x<-c(\"Aaa bbb Aaa bbb\", \"Aaa Bbb Aaa Bbb\", \"Aaa bbb Aaa bbb\"); p<-\"(?<first>[[:upper:]][[:lower:]]+) (?<last>[[:upper:]][[:lower:]]+)\"; gregexpr(p, x, perl=TRUE) }");
assertEval("gregexpr(')', 'abc()', fixed = TRUE)");
assertEval("gregexpr('(', 'abc()', fixed = TRUE)");
assertEval("gregexpr(')', 'abc()', fixed = FALSE)");
assertEval("gregexpr('\\\\)', 'abc()', fixed = FALSE)");
assertEval(Output.IgnoreErrorMessage, "gregexpr('(', 'abc()', fixed = FALSE)");
assertEval("gregexpr('\\\\(', 'abc()', fixed = FALSE)");
}
}
......@@ -118,5 +118,11 @@ public class TestBuiltin_regexpr extends TestBase {
assertEval("{ x<-c(\"Aaa bbb Aaa bbb\", \"Aaa Bbb Aaa Bbb\"); p<-\"(?<first>[[:upper:]][[:lower:]]+) (?<last>[[:upper:]][[:lower:]]+)\"; regexpr(p, x, perl=TRUE) }");
assertEval("{ x<-c(\"Aaa bbb Aaa bbb\", \"Aaa Bbb Aaa Bbb\", \"Aaa bbb Aaa bbb\"); p<-\"(?<first>[[:upper:]][[:lower:]]+) (?<last>[[:upper:]][[:lower:]]+)\"; regexpr(p, x, perl=TRUE) }");
assertEval("regexpr(')', 'abc()', fixed = TRUE)");
assertEval("regexpr('(', 'abc()', fixed = TRUE)");
assertEval("regexpr(')', 'abc()', fixed = FALSE)");
assertEval("regexpr('\\\\)', 'abc()', fixed = FALSE)");
assertEval(Output.IgnoreErrorMessage, "regexpr('(', 'abc()', fixed = FALSE)");
assertEval("regexpr('\\\\(', 'abc()', fixed = FALSE)");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment