# Select rows of a matrix in which entires in a column contain particular text

data={{one,a,16,2},{one,b,18,2},{one,c,28,3},{one_ave,d,45,4},{two,a,47,2},{two,b,8,6},{two,c,33,17},{two_ave,d,4,4}};


For the matrix above, I want to select all those rows in which the first column contains the text "ave" (i.e. rows 4 and 6). To get those columns containing "two_ave"...

Select[data, #[[1]] == two_ave &]


...obviously works. I was hoping replacing the "two' with a wildcard might get the job done, but I can't seem to get it to work. I've had a good search around but can't find the answer. Can anybody help?

Select[StringMatchQ["*ave"] @* ToString @* First][data]

 {{one_ave, d, 45, 4}, {two_ave, d, 4, 4}}

• @TimJ, you can use Select[Not@*StringMatchQ["*ave"]@*ToString@*First][data] to exclude rows containing "*ave".