On Sun, Feb 15, 2009 at 5:09 AM, Jay Jesus Amorin <jay.amo...@gmail.com>wrote:

> Hi,
>
> Can you please help my how to parse.
>
> url = http://this/is/my/url/to/parse
>
> how do i parse url to print "http://this/is/my/url/to";
>
> i want to remove the last part of my url with is "parse". I would like to
> remove the last string of my url.
>
> i have try split, but i think it wont work as i dont know how long my url
> would be in my real application.
>
> Thanks,
>
>
> Newbie,
>
> Jay
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
> I'm not sure this is the best strategy, but it seems to work:

>>> url ="http://this/is/my/url/to/parse";
>>> m = url.replace("//", '/').split("/")
>>> n = m[0]+"//"+"/".join(new[1:])
>>> n
'http://this/is/my/url/to'
>>>




-- 
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.....محمد
الغزالي
"No victim has ever been more repressed and alienated than the truth"

Emad Soliman Nawfal
Indiana University, Bloomington
http://emnawfal.googlepages.com
--------------------------------------------------------
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to