Builds the regular expression used to select the rows of an Airtable asset
table (taxa, gear, vessels, sites, geo) that belong to one or more
forms.
Value
A length-1 character string: a regex matching any of form_ids as a
whole element of a comma-separated list.
Details
form_id in the assets snapshot is a linked-record field. airtable_to_df()
collapses it with paste(collapse = ", "), so a record shared by three forms
arrives as a single string "recA, recB, recC". Selecting a form's records
therefore needs a whole-element match rather than a substring test.
Both degenerate inputs are rejected rather than tolerated, because both fail
silently downstream: a zero-length id makes paste0() recycle into a pattern
that matches only empty strings — every asset table comes back empty and
every join yields NA, with no error anywhere — and a multi-element pattern
makes stringr::str_detect() recycle element-wise against the data instead
of testing alternatives.
Examples
form_id_pattern("recAAAAAAAAAAAAAA")
#> [1] "(^|,\\s*)(recAAAAAAAAAAAAAA)(\\s*,|$)"
form_id_pattern(c("recAAAAAAAAAAAAAA", "recBBBBBBBBBBBBBB"))
#> [1] "(^|,\\s*)(recAAAAAAAAAAAAAA|recBBBBBBBBBBBBBB)(\\s*,|$)"
