From: w_a_x_man Date: 2010-11-05T03:10:14+09:00 Subject: Re: Regular Expression On Nov 3, 10:42 am, w_a_x_man wrote: > > "We don't need no stinkin' loops!" > > def check input >   return false  unless /\A[A-D]{0,4}\z/ =~ input >   %w(A B C D).map{|s| input.count s}.zip( [1,1,1,2] ). >     map{|a,b| b-a}.all?{|n| n >= 0} > end def check input /\A[A-D]{0,4}\z/.match input and %w(A B C D).map{|s| input.count s}.zip( [1,1,1,2] ). map{|a,b| b-a}.min >= 0 end