• set_regexpr_style() selects the style explicitly.

  • auto_set_regexpr_style() chooses based on OS (TRE on Windows; PCRE elsewhere).

  • set_PCRE() and set_TRE() force the style.

set_PCRE()

set_TRE()

use_perl()

set_regexpr_style(style)

auto_set_regexpr_style()

Arguments

style

one of 'PCRE' or 'TRE'

Value

Logical indicating whether to use perl

Details

These functions do not change the behavior of gsub()/regexpr() directly. They set a global option that you can read via use_perl() and pass to gsub()/regexpr().

References

https://stackoverflow.com/questions/47240375/regular-expressions-in-base-r-perl-true-vs-the-default-pcre-vs-tre

Author

Guangchuang Yu