grep replacement in pure Ruby