Closed brodieG closed 7 years ago
Actually, the problem is in rematch2::re_exec_all
. "Fix" might be to just add a perl
formal with default TRUE to that function, but I'm not sure if you default to perl for any specific reason (other than wouldn't it be nice if all R regular expressions were perl, cough regexec cough).
For capture groups, you need perl = TRUE
and rematch2
works best for these. But yeah, adding a perl = TRUE
somewhere is a good fix.
So to get stuff to work with ansi_strwrap
I took the liberty of adding this argument to rematch2. Seems like this is something that we can't just merge without thinking through the implications.
Here is my branch. All tests past FWIW, but the documentation is no longer technically correct since you can now pass perl=FALSE
(though presumably that breaks stuff, or does it just fail to capture subgroups) so it's not just using PCRE as per the function titles.
Re capture groups, I they work with the (buggy) TRE implementation:
x <- "hello there how are you today sir"
regmatches(x, regexec("\\w+ (\\w+) \\w+", x, perl=F))
## [[1]]
## [1] "hello there how" "there"
but that only does the first one. Also, to my astonishment regexec
appears to now support perl. I think this is new.
That's good, can you pls submit a PR to rematch2
?
Will do, just need to clean few things up.
OK, so with the rematch2
change, this is fixed, right?
Yes, fixed as far as I can tell.