From: Mark Thomas Date: 2009-11-13T21:30:16+09:00 Subject: Re: DRYing a Regex On Nov 13, 2:34 am, RichardOnRails wrote: > Hey Caleb & James, > > With your insights,  I was able to cut down 18 lines of somewhat > obscure code to 6 lines that I find very readable.  That's such and > improvement on the quality of the code. I believe you can go further. For example, these three lines: sNewList = %{TMxxx CSCO COL INTC BRCM FDX AA CAT BUR FSLR MSFT', PNC HPQ CSCO AMAT ORCL FCX ABX PVTB XHB CSCO TM FDX} aRawNewList = sNewList.scan(/[A-Z]+/) aNewList = Set.new(aRawNewList ).to_a.sort can be replaced by one: aNewList = %W{TMxxx CSCO COL INTC BRCM FDX AA CAT BUR FSLR MSFT', PNC HPQ CSCO AMAT ORCL FCX ABX PVTB XHB CSCO TM FDX} (you can add .sort to the end but I don't think you need it) also, consider something like this: hCurrentList.delete_if { |key,v| aNewList.include?key } -- Mark.