I have a regular expression that is correctly parsed by grepl
but generates an error when used as pattern
of str_extract_all
.
I'm using stringr
v1.0.0, R
v3.2.3 under OSX.
In this question a regex passed to a stringr
generates a similar error, yet the solution proposed doesn't apply in my case.
require(stringr)
string <- "Decreto Legislativo 6 marzo 1992, n. 248; G.U. n. 77 del 1° aprile 1992"
it_months <- c("gennaio","febbraio","marzo","aprile","maggio","giugno","luglio",
"agosto","settembre","ottobre","novembre","dicembre")
grep_it_date <- paste0("\\d{1-2}(º?) (", paste(it_months, collapse="|") ,") \\d{4}$")
grepl(grep_it_date, string)
# [1] TRUE
dates_from_string <- str_extract_all(tolower(string), grep_it_date, simplify = TRUE)
# Error in stri_extract_all_regex(string, pattern, simplify = simplify, :
# Error in {min,max} interval. (U_REGEX_BAD_INTERVAL)