a regual expression problem
Roy Smith
roy at panix.com
Sun Nov 30 09:59:11 EST 2008
In article
<8cb784fc-809b-444e-b8a7-e4129a4a58ee at w24g2000prd.googlegroups.com>,
lookon <areyoulookon at gmail.com> wrote:
> I have a url of image, and I want to get the filename and extension of
> the image. How to write in python?
>
> for example, the url is http://a.b.com/aaa.jpg?version=1.1
>
> how can I get aaa and jpg by python?
Despite the subject line, this is *not* a regex problem. The right tool is
Python's built-in urlparse module, which understands the full syntax of
urls. Trying to roll your own from scratch using split() or regex is the
wrong solution.
More information about the Python-list
mailing list