From: Robert Klemme Date: 2008-02-12T16:45:23+09:00 Subject: Re: non case sensitive searching 2008/2/12, Adam Akhtar : > the reg exp. looks good but when i try to apply it to help me romove > duplicates from a list it doesnt seem to work > > list = %w{adam Adam bobby Bobby wild wILd} > list.sort The line above is ineffective because you do not sort the original list. > list.each_index do |x| > list.delete_at(x) if (/list[x]/i =~ list[x+1]) #remove entries which > have same spelling but in diff. case > end > puts "" > puts list I would use another algorithm because of efficiency: #!/bin/env ruby require 'set' # ensure random order list = %w{adam Adam bobby Bobby wild wILd}.sort_by { rand } dups = Set.new p list list.delete_if {|w| not dups.add? w.downcase } p list Kind regards robert -- use.inject do |as, often| as.you_can - without end