From: Sebastian Hungerecker Date: 2008-01-11T05:51:35+09:00 Subject: Re: string extraction Li Chen wrote: > What is the Ruby way to extract a string like this? > > old_string="5'-AAAAAAAA    CCCCCCCC  TTT   GGGGG    GGGG-3'" > new_string="AAAAAAAACCCCCCCCTTTGGGGGGGGG" new_string = old_string.gsub(/[^ACTG]/i,"") This removes anything that is not an A, C, T or G (case insensitively. If you want lower case chars acgt to be removed, too, remove the i from the regex). HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826