From accbed0b439351737f8744abc2c96d8682be6fd3 Mon Sep 17 00:00:00 2001 From: qinwf Date: Sun, 24 Apr 2016 00:07:25 +0800 Subject: [PATCH] Update: use is.character instead of inherits to check type --- R/extract.R | 2 +- R/match.R | 2 +- R/replace.R | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/extract.R b/R/extract.R index d571b35..a08ac20 100644 --- a/R/extract.R +++ b/R/extract.R @@ -45,7 +45,7 @@ #' re2_extract("test@me.com", "(.*)@([^.]*)", "\\2!\\1") #' @export re2_extract = function(input, pattern, rewrite = "\\1", ...) { - if (!inherits(pattern, "re2exp")) { + if (is.character(pattern)) { pattern = re2(pattern, ...) } cpp_extract(input, pattern, rewrite) diff --git a/R/match.R b/R/match.R index 83c5f2f..cfc85fd 100644 --- a/R/match.R +++ b/R/match.R @@ -66,7 +66,7 @@ re2_match = function(input, anchor = "none", all = FALSE, ...) { - if (!inherits(pattern, "re2exp")) { + if (is.character(pattern)) { pattern = re2(pattern, ...) } cpp_match(input, pattern, value, anchor, all) diff --git a/R/replace.R b/R/replace.R index 75e1d10..140d7ed 100644 --- a/R/replace.R +++ b/R/replace.R @@ -49,7 +49,7 @@ #' re2_replace("yabba dabba doo", "b+","d", all = FALSE) == "yada dabba doo" #' @export re2_replace = function(input, pattern, rewrite, all = FALSE, ...) { - if (!inherits(pattern, "re2exp")) { + if (is.character(pattern)) { pattern = re2(pattern, ...) } cpp_replace(input, pattern, rewrite, all)