fork download
  1. library(stringr)
  2. from <- c("Valid from", "Zipcode from", "0000AA", "1798AA", "8900AA", "9167aa")
  3. to <- c("Valid from", "Zipcode to", "1797zz", "8899ZZ", "9166ZZ", "9999ZZ")
  4. str_detect(from, "^\\d{4}[A-Za-z]{2}$")
  5. from[str_detect(from, "^\\d{4}[A-Za-z]{2}$")]
  6.  
  7. str_detect(to, "^\\d{4}[A-Za-z]{2}$")
  8. to[str_detect(to, "^\\d{4}[A-Za-z]{2}$")]
Success #stdin #stdout 0.24s 42188KB
stdin
Standard input is empty
stdout
[1] FALSE FALSE  TRUE  TRUE  TRUE  TRUE
[1] "0000AA" "1798AA" "8900AA" "9167aa"
[1] FALSE FALSE  TRUE  TRUE  TRUE  TRUE
[1] "1797zz" "8899ZZ" "9166ZZ" "9999ZZ"