Better way to isolate string

Tim Golden mail at timgolden.me.uk
Fri May 11 11:45:21 EDT 2007


HMS Surprise wrote:
> 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>'

Only if you're competing in an obscurity competition ;)

If you're really confined to built-ins (ie you can't import
a single module) then just go with your original solution.
Why not?

If you can import modules, then you want to look
at the urlparser and cgi modules, I suspect.

TJG



More information about the Python-list mailing list