parse_regex_pattern {stringmagic}R Documentation

stringmagic's regular expression parser

Description

Parse regular expression with custom flags and obtain the final pattern to be parsed as well as the vector of flags

Usage

parse_regex_pattern(
  pattern,
  authorized_flags,
  parse_flags = TRUE,
  parse_logical = TRUE,
  envir = parent.frame()
)

Arguments

pattern

Character scalar, the regular expression pattern to parse.

authorized_flags

Character vector representing the flags to be parsed. Use the empty string if no flags are allowed.

parse_flags

Logical scalar, default is TRUE. Whether to parse the optional regex flags.

parse_logical

Logical scalar, default is TRUE. Whether to parse logical regex operations, similarly to string_get().

envir

An environment, default is parent.frame(). Only used if the flag magic is present, it is used to find the variables to be interpolated.

Details

This is an internal tool that is exposed in order to facilitate checking what's going on.

There is no error handling.

Value

This function always returns a list of 4 elements:

Author(s)

Laurent Berge

See Also

String operations: string_is(), string_get(), string_clean(), string_split2df(). Chain basic operations with string_ops(). Clean character vectors efficiently with string_clean().

Use string_vec() to create simple string vectors.

String interpolation combined with operation chaining: string_magic(). You can change string_magic default values with string_magic_alias() and add custom operations with string_magic_register_fun().

Display messages while benefiting from string_magic interpolation with cat_magic() and message_magic().

Other tools with aliases: cat_magic_alias(), string_magic(), string_magic_alias(), string_ops_alias(), string_vec_alias()

Examples


parse_regex_pattern("f/hello", c("fixed", "ignore"))

x = "john"
parse_regex_pattern("fm/{x} | Doe", c("fixed", "ignore", "magic"))


[Package stringmagic version 1.1.2 Index]