Suppose I have the following list:
list = {w, r, {f, first, t, y}, {a, y}, last, {k, r, first, e}, m, e, last, r, t}
I am expecting this
Cases[list, {__, {__, first, x__}, y__, last, __} :> {{first, x}, y,
last}]
to result in this
(*{{{first, t, y}, {a, y}, last}, {{first, e}, m, e, last}}*)
and this
Cases[Flatten@list, {__, first, x__, last, __} :> {first, x, last}]
to result in this
(*{{first, t, y, a, y, last}, {first, e, m, e, last}}*)
but the results for both are {}.
How can I build a suitable pattern to get the desired results?