R/extr_substr.R

Defines functions extr_substr

# equivalent to str_extract()
extr_substr <- function(string, regex){
  matches <- regexpr(regex, string, perl = TRUE)
  str_out <- vector(mode = "character", length = length(matches))
  str_out[matches < 0] <- NA_character_
  str_out[matches >= 0] <- regmatches(string, matches)
  return(str_out)
}

Try the DSSAT package in your browser

Any scripts or data that you put into this service are public.

DSSAT documentation built on Nov. 9, 2023, 1:08 a.m.