re_fullmatch {re} | R Documentation |
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.
re_fullmatch(pattern, string, ...)
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
|
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.
Python re.fullmatch() documentation
pattern <- re_compile("\\d{3}-\\d{2}-\\d{4}")
re_fullmatch(pattern, "123-45-6789") # Full match
re_fullmatch("123-45-6789", "123-45-6789 and more") # No full match