Moved pattern matching from grep to ruby