dttm_fmt_to_regex: Convert a parsed date/time format to regex

View source: R/parse_dttm_fmt.R

dttm_fmt_to_regexR Documentation

Convert a parsed date/time format to regex

Description

dttm_fmt_to_regex() takes a tibble of parsed date/time format components (as returned by parse_dttm_fmt()), and a mapping of date/time component formats to regexps and generates a single regular expression with groups for matching each of the date/time components.

Usage

dttm_fmt_to_regex(
  fmt,
  fmt_regex = fmt_rg(),
  fmt_c = fmt_cmp(),
  anchored = TRUE
)

Arguments

fmt

A format string (scalar) to be parsed by patterns.

fmt_regex

A named character vector of regexps, one for each date/time component.

anchored

Whether the final regex should be anchored, i.e. bounded by "^" and "$" for a whole match.

Value

A string containing a regular expression for matching date/time components according to a format.


sdtm.oak documentation built on April 3, 2025, 9:37 p.m.