Wednesday, July 4, 2012

Re: Use regular expression to retrieve all image tags from a given content

On 07/04/12 08:30, Melvyn Sopacua wrote:
> On 4-7-2012 3:03, Tim Chase wrote:
>> [snip Tim's obscene regex]
>
> Aside from the \b matching positive against ><,

I'm not sure I follow...the \b just requires that a word-boundary
occur there, preventing it from matching something like "imgood".
It might even be vestigial as I originally had "*" rather than "+"
for the whitespace before attributes, so it could likely be removed
now without impacting the regexp.

> My main beef with modern software is that for the simplest of things one
> flees to full-blown libraries which happen to provide some utilities,
> but the other 98% of the code from that library is unused. Case in
> point, PIL to verify if a file is an image. But my rant alarm went off. :)

I've done enough work where pathological client/user data comes
through that I swear sometimes they're TRYING to break the app.
Like the person who uploaded an Excel file with a .jpg extension to
try and post the contained graph (re. your PIL image-detection comment).

So it all boils down the use case, and how much work you want to
spend maintaining it every time it breaks. If security is involved,
I want the best-tested library I can get so I don't have to make all
their mistakes myself. If it's just a dirty "get me adequate data
as fast as possible" (especially if it's a one-off for a single
data-source), then I'll often just hammer it out using whatever is
easiest.

> But the author I replied to did.

Ah. I was looking for a 2nd post in the thread from the OP ("Mo
Mughrabi") and didn't see anything. At least via gmane where I read
the list.

> I think you and I are on the same page.
> Either way, the OP now has some nice examples of how to /refine/ regular
> expressions and that's the real craft :).

Amen! :-)

-tim



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment