New answers tagged

12

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...


10

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*"] ...



Top 50 recent answers are included