Saturday, June 30, 2012

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

Why not use html parse lib? BeautifulSoup( for expample

from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup('put_youp_html_code_as_string')
images = soup.find_all('img')

If you need exactly regular expressions, watch this video:

суббота, 30 июня 2012 г., 20:37:13 UTC+8 пользователь mo.mughrabi написал:

am really a noob with regular expressions, I tried to do this on my own but I couldn't understand from the manuals how to approach it. Am trying to find all img tags of a given content, I wrote the below but its returning None

 content = i.content[0].value
= re.compile(r'^<img')
= prog.match(content)
print result

any suggestions?

You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment