Extract variables debug

If the match fails

  • too_few = "debug"
df <- tribble(
  ~str,
  "<Sheryl>-F_",
  "<Kisha>@-F_45", 
  "<Brandon>-N_33",
  "<Sharon>-F_38", 
  "<Penny>-F_58",
  "<Justin>-M_41", 
  "<Patricia>-F_84", 
)


df |> 
  separate_wider_regex(
    str,
    patterns = c(
      "<", 
      name = "[A-Za-z]+", 
      ">-", 
      gender = ".",
      "_",
      age = "[0-9]+"
    ),
    too_few = "debug"
  )
## Warning: Debug mode activated: adding variables `str_ok`, `str_matches`, and
## `str_remainder`.
## # A tibble: 7 × 7
##   name     gender age   str             str_ok str_matches str_remainder
##   <chr>    <chr>  <chr> <chr>           <lgl>        <int> <chr>        
## 1 Sheryl   F      <NA>  <Sheryl>-F_     FALSE            5 ""           
## 2 Kisha    <NA>   <NA>  <Kisha>@-F_45   FALSE            2 ">@-F_45"    
## 3 Brandon  N      33    <Brandon>-N_33  TRUE             6 ""           
## 4 Sharon   F      38    <Sharon>-F_38   TRUE             6 ""           
## 5 Penny    F      58    <Penny>-F_58    TRUE             6 ""           
## 6 Justin   M      41    <Justin>-M_41   TRUE             6 ""           
## 7 Patricia F      84    <Patricia>-F_84 TRUE             6 ""