Better way to isolate string

HMS Surprise john at datavoiceint.com
Fri May 11 11:21:28 EDT 2007


Greetings.

Given the string s below and using only  python built-in capabilities,
I am trying to isolate the substring G132153. This string may have any
number of digits but the pieces around it will not change. I have
accomplished this with split but there must be a more elegant and
compact way to do this.


>>> s ='<a href="../active/Group_Detail.php?GroupID=G132153&SvcType=1&AType=V" class="dvLink">G132153</a>'
>>> t = s.split('">')
>>> u = t[-1].split('<')
>>> v = u[0]
>>> v
'G132153'


Thanks,

jvh




More information about the Python-list mailing list