Re: [Rd] error handling in strcapture

2016-10-04 Thread Michael Lawrence
Once again, nice catch. I've committed a check for this. Michael On Tue, Oct 4, 2016 at 2:37 PM, William Dunlap wrote: > It is also not catching the cases where the number of capture expressions > does not match the number of entries in proto. I think all of the following > should give an error

Re: [Rd] error handling in strcapture

2016-10-04 Thread William Dunlap via R-devel
It is also not catching the cases where the number of capture expressions does not match the number of entries in proto. I think all of the following should give an error about the mismatch. > strcapture("(.)(.)", c("ab", "cde", "fgh", "ij", "lm"), proto=list(A="",B="",C="")) A B C 1 a b c

Re: [Rd] error handling in strcapture

2016-10-04 Thread Michael Lawrence
Hi Bill, This is a bug in regexec() and I will commit a fix. Thanks for the report, Michael On Tue, Oct 4, 2016 at 1:40 PM, William Dunlap wrote: > I noticed a problem in the strcapture from R-devel (2016-09-27 r71386), when > the text contains a missing value and perl=TRUE. > > { > # NA

Re: [Rd] error handling in strcapture

2016-10-04 Thread William Dunlap via R-devel
I noticed a problem in the strcapture from R-devel (2016-09-27 r71386), when the text contains a missing value and perl=TRUE. { # NA in text input should map to row of NA's in output, without warning r9p <- strcapture(perl = TRUE, "(.).* ([[:digit:]]+)", c("One 1", NA, "Fifty 50"), dat

Re: [Rd] error handling in strcapture

2016-09-21 Thread Michael Lawrence
The new behavior is that it yields NAs when the pattern does not match (like strptime) and for empty captures in a matching pattern it yields the empty string, which is consistent with regmatches(). Michael On Wed, Sep 21, 2016 at 2:21 PM, William Dunlap wrote: > If there are any matches then st

Re: [Rd] error handling in strcapture

2016-09-21 Thread William Dunlap via R-devel
If there are any matches then strcapture can see if the pattern has the same number of capture expressions as the prototype has columns and give an error if not. That seems appropriate. If there are no matches, then there is no easy way to see if the prototype is compatible with the pattern, so s

Re: [Rd] error handling in strcapture

2016-09-21 Thread Michael Lawrence
Hi Bill, Thanks, another good suggestion. strcapture() now returns NAs for non-matches. It's nice to have someone kicking the tires on that function. Michael On Wed, Sep 21, 2016 at 12:11 PM, William Dunlap via R-devel wrote: > Michael, thanks for looking at my first issue with utils::strcaptur

[Rd] error handling in strcapture

2016-09-21 Thread William Dunlap via R-devel
Michael, thanks for looking at my first issue with utils::strcapture. Another issue is how it deals with lines that don't match the pattern. Currently it gives an error > strcapture("(.+) (.+)", c("One 1", "noSpaceInLine", "Three 3"), proto=list(Name="", Number=0)) Error in strcapture("(.+) (.+)"