I suppose a one liner would look better, but I am alway leery of these things 'breaking'. t = s.split('">')[-1].split('<')[0] s ='<a href="../active/Group_Detail.php? GroupID=G132153&SvcType=1&AType=V" class="dvLink">G132153</a>' jh