I have one long string "M. tuberculosis H37Rv|Rv0153c|ptbB
out put should look like this:
"370153"
or
"M.tuberculosisHRv|Rvc|ptbB<b"
thanks
I have one long string "M. tuberculosis H37Rv|Rv0153c|ptbB
out put should look like this:
"370153"
or
"M.tuberculosisHRv|Rvc|ptbB<b"
thanks
Try this:
In [4]: ''.join([x for x in s if x.isdigit()])
Out[4]: '370153'
and the fastest way is:
In [4]: ''.join((x for x in s if x.isdigit()))
Out[4]: '370153'