replace numbers in a string
Gary Herron
gherron at islandtraining.com
Thu Oct 9 04:31:05 EDT 2008
Beema Shafreen wrote:
> hi All,
>
> i have few lines in file
> "ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg"
> i need to replace the number and get only the alphabet in such a case
> what should i do.
> Can any body suggest me
>From the regular expression module, use re.sub like this:
>>> import re
>>> re.sub('[0-9]', '',
"ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg")
'ttccatttctggacatgacgtctgtggtttaagctttgtgaaagaatgtgctttgattcg'
Gary Herron
>
> --
> Beema Shafreen
> ------------------------------------------------------------------------
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list