regular expression for parsing an html element

Wojciech Muła wojciech_mula at poczta.null.onet.pl.invalid
Fri Apr 20 15:30:42 EDT 2007


abcd wrote:
> My regex so far is:  src=\"(.*)\" ....however the group in this case
> would end up being, image/blah/a.jpg" id="ddddd">blah blah blah</
> a>.....
> 
> how can I tell the regex group (.*) to end when it gets to the first
> " ?

Use non-greedy matching, i.e. src=\"(.*?)\" (question mark after *.)
See: http://docs.python.org/lib/re-syntax.html

w.



More information about the Python-list mailing list