2

In R you can use a replacement function such as gsub to find and replace with regular expressions. I've seen some use PERL=TRUE as an additional argument, but I wonder when this is necessary? Which flavor does R use by default? And what more can the PERL version do? When should one use the PERL variant and when shouldn't he?

Bram Vanroy
  • 22,919
  • 16
  • 101
  • 195
  • 1
    There is a difference between the `POSIX` standard regex, and the perl-compatible (PCRE) regex. The latter supports macros like `\w`. That might be the distinction. (Don't really know R though) – Sobrique May 07 '15 at 12:19
  • 1
    @Moody_Mudskipper This question was asked two years before your proposed duplicate... – Bram Vanroy Jun 15 '18 at 17:59
  • Yes but the other one fits better, people will land on that one, the wording is better and the existing answer is more interesting. The meta's guidelines are fine with designing a younger duplicate and well, it's technically possible for a reason :) – Moody_Mudskipper Jun 15 '18 at 18:52
  • Just noticed it was your question. I'll just add that designing as duplicate is not a criticism on the legitimity of a question, it's just to route other users efficiently to what would be best for them. – Moody_Mudskipper Jun 15 '18 at 18:55

2 Answers2

1

There are several regular expression standards. In R you can choose between POSIX and PCRE.

There are tons of little differences between them, the most important one is POSIX always finds the longest match while PCRE stops at the first one.

PCRE template also needs to be included in delimeters (e.g. /like this/ |or this|).

Vadim Pushtaev
  • 2,182
  • 15
  • 32
0

By default R uses POSIX extended regular expressions , If perl is set to TRUE, R will use the Perl 5 flavor of regular expressions as implemented in the PCRE library

check this Regular expressions in R

Nader Hisham
  • 4,224
  • 4
  • 15
  • 33