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