Why does the following code evaluate differently?
For example:
str_detect(c('12312312','PO123123', 'ABCDDBCA'),'((\\d)|(A-Z)){8}')
evaluates to
TRUE FALSE FALSE
While
str_detect(c('12312312','PO123123', 'ABCDDCBA'),'[\\d|A-Z]{8}')
evaluates to
TRUE TRUE TRUE
I understand that the '''|''' character in the second expression is not needed, as within square brackets it is treated as a literal character rather than the or symbol but nonetheless I don't understand why the first regex doesn't evaluate to TRUE TRUE TRUE
Thank you
I expected both to evaluate to TRUE TRUE TRUE