Skip to contents

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.

Usage

re_fullmatch(pattern, string, ...)

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_compile

IGNORECASE

Flag to indicate case-insensitive matching.

I

Abbreviation for IGNORECASE.

MULTILINE

Flag to indicate multi-line matching, where ^ and $ match the start and end of each line.

M

Abbreviation for MULTILINE.

DOTALL

Flag to indicate that . (dot) should match any character including newline.

S

Abbreviation for DOTALL

VERBOSE

Flag to allow a more verbose regex syntax, which can include comments and whitespace for readability.

X

Abbreviation for VERBOSE

NOFLAG

Flag 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
#>