starts_with_a <- function(x) grepl("^a", x)
p <- function() {
one_or_more(satisfy(starts_with_a)) %then%
(literal("~End") %ret% NULL) %then%
Ignore() %then%
eof()
}
p()(c("ab", "abc", "~End", "boring stuff", "more stuff"))
Run the code above in your browser using DataLab