A common pattern is something like this:
// S is of the form "foo[bar]baz", get bar out.
size_t open = S.find("[");
if (open != npos) {
size_t close = S.find("]", open);
if (close != npos) {
StringRef middle = S.slice(open, close);
// Do something
}
}I want to simplify the above by turning it into one line:
StringRef middle = S.scan_between("[", "]");This patch addresses this.
This description is not 100% accurate. See my next comment.