<br />
> mat=matrix(c('as','sd','abc','ef','er','sd','wa','sw','abe'),nrow=3,byrow=T)<br />
> n <- apply(mat, 1, function(x) length(grep('ab',x)))<br />
> mat[n[n>0],]<br />
[,1] [,2] [,3]<br />
[1,] "as" "sd" "abc"<br />
[2,] "as" "sd" "abc"<br />
</p>