0

Why is it that in R when using a single square brackets here returns FALSE, whereas using double square brackets returns TRUE? Example:

> grepl('[:alpha:]', 'AA')
[1] FALSE
> grepl('[[:alpha:]]', 'AA')
[1] TRUE
pd441
  • 2,644
  • 9
  • 30
  • 41

1 Answers1

-1

[[:alpha:]] is a specific character class unique to regex in R. Check out character classes here

https://www.rstudio.com/wp-content/uploads/2016/09/RegExCheatsheet.pdf

M. Stolte
  • 105
  • 1
  • 1
  • 11
  • 1
    The mere fact they are called *POSIX* character classes implies they are not unique to R regex. And you may use `[:alpha:]`, too, but with `stringr` functions that are powered with the ICU regex library. – Wiktor Stribiżew Mar 27 '19 at 14:39