naxp_accepts() says whether a naxp accepts each text, and
naxp_canonical_form() gives the form each accepted text decodes to.
Arguments
- text
A character vector.
- naxp
A naxp from
naxp_parse(), a pattern string or a naxp_encoded vector, whose naxp is used. Fornaxp_decode(), it is needed only wherexis not a naxp_encoded vector.
Value
naxp_accepts(): a logical vector the same length astext, with its names. It isFALSE, neverNA, forNAand for invalid text.naxp_canonical_form(): a character vector the same length astext, with its names, holdingNAforNAand for invalid text.
Examples
nl_postcode <- naxp_parse(r"(\9\9\9\9 \s!! \A\A)")
naxp_accepts(c("1012AB", "1012 AB", "1012-AB"), nl_postcode)
#> [1] TRUE TRUE FALSE
naxp_canonical_form(c("1012AB", "1012 AB", "1012-AB"), nl_postcode)
#> [1] "1012 AB" "1012 AB" NA