Sebastian Hungerecker
1/10/2008 8:52:00 PM
Li Chen wrote:
> What is the Ruby way to extract a string like this?
>
> old_string=3D"5'-AAAAAAAA =C2=A0 =C2=A0CCCCCCCC =C2=A0TTT =C2=A0 GGGGG =
=C2=A0 =C2=A0GGGG-3'"
> new_string=3D"AAAAAAAACCCCCCCCTTTGGGGGGGGG"
new_string =3D old_string.gsub(/[^ACTG]/i,"")
This removes anything that is not an A, C, T or G (case insensitively. If y=
ou=20
want lower case chars acgt to be removed, too, remove the i from the regex).
HTH,
Sebastian
=2D-=20
Jabber: sepp2k@jabber.org
ICQ: 205544826