Position and string patterns

For large lists, this should be snappy:

Pick[Range@Length@dat, StringTake[dat, UpTo@4], "star"]

and actually, taking advantage of listability,

Pick[Range@Length@dat, StringMatchQ[dat, "star*"]]

is a bit faster it seems...


Position[dat, _String?(StringMatchQ[#, "star" ~~ ___] &)]

or

Position[dat, _String?(StringMatchQ[#, "star*"] &)]

or

Position[dat, _?(StringMatchQ[#, "star*"] &), Heads -> False]

or

Position[StringMatchQ[dat, "star*"], True] (*thanks: @TomD *)

{{1}, {7}, {13}, {19}}

Alternatively,

Pick[Range@Length@dat, StringMatchQ[#, "star*"] & /@ dat]

{1, 7, 13, 19}