re_fullmatch checks whether each element of a character vector fully matches a specified pattern
(regular expression). If the provided pattern is not already a compiled pattern object, it compiles it using
re_compile. The function ensures that the entire string matches the pattern from start to end.
Arguments
- pattern
A regular expression pattern or a compiled pattern object.
- string
A character vector where each element is a string to be matched against the pattern.
- ...
Arguments passed on to
re_compileIGNORECASEFlag to indicate case-insensitive matching.
IAbbreviation for IGNORECASE.
MULTILINEFlag to indicate multi-line matching, where
^and$match the start and end of each line.MAbbreviation for MULTILINE.
DOTALLFlag to indicate that
.(dot) should match any character including newline.SAbbreviation for DOTALL
VERBOSEFlag to allow a more verbose regex syntax, which can include comments and whitespace for readability.
XAbbreviation for VERBOSE
NOFLAGFlag to indicate that no flags should be set.
Value
A list where each element is a character vector containing the full match for the corresponding element of
string, or character(0) if there is no match.
Examples
pattern <- re_compile("\\d{3}-\\d{2}-\\d{4}")
re_fullmatch(pattern, "123-45-6789") # Full match
#> [[1]]
#> [1] "123-45-6789"
#>
re_fullmatch("123-45-6789", "123-45-6789 and more") # No full match
#> [[1]]
#> [1] NA
#>