You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know what would be the most appropriate regular expression, but instead I can propose this inelegant yet efficient function as a workaround to start with:
bracket_content<-function(string, open="\\(", close="\\)"){
openings<- gregexpr(open, string)[[1]]
closings<- gregexpr(close, string)[[1]]
if(length(openings) != length(closings) || any(rev(closings) <openings)){
stop("Invalid brackets specifications")
}
substr(x=string, start=openings[1], stop=closings[length(closings)])
}
bracket_content("sex (0 for male (default), 1 for female)")
#> [1] "(0 for male (default), 1 for female)"
bracket_content("sex (0 for male (default), 1 for female") # missing closing bracket#> Error in bracket_content("sex (0 for male (default), 1 for female"): Invalid brackets specifications
bracket_content("sex (0 for male) (1 for female)") # multiple brackets#> Error in bracket_content("sex (0 for male) (1 for female)"): Invalid brackets specifications
bracket_content("sex") # empty string#> [1] ""
bracket_content("sex (0 male, 1 female) [and options]", "\\[", "\\]") # works with square brackets too#> [1] "[and options]"
Hi Kyle,
Annotation parsing fails with nested (or multiple) brackets
This is due to this regular expression currently implemented.
mrgsolve/R/annot.R
Line 73 in c125cdb
I don't know what would be the most appropriate regular expression, but instead I can propose this inelegant yet efficient function as a workaround to start with:
Created on 2023-08-22 with reprex v2.0.2
Best regards
Félicien
The text was updated successfully, but these errors were encountered: