Regular Expression problem

Paul McGuire paul at alanweberassociates.com
Sun Jul 16 13:19:05 EDT 2006


> 
> Less is more:
> 
> pat = re.compile(r'href="([^"]+)')
> pat.search(your_link)
> 
> 

Be sure to also catch:

<link type="text/css" HREF="mystylesheet.css" rel="stylesheet"> 
<link type="text/css" href=mystylesheet.css rel="stylesheet"> 
<link type='text/css' href='mystylesheet.css' rel='stylesheet'> 

And it's not certain whether the OP is interested in tags like:

<a href="blah.html">

-- Paul




More information about the Python-list mailing list