[Tutor] How do I make pattern to find only '.html' file using Python Regular Expression?

Abdullah Al Imran abdalimran at live.com
Wed Apr 1 21:22:05 CEST 2015


I have some HTML content where there are many links as the following pattern:

<a href="http://example.com/2013/01/problem1.html">Problem No-1</a><br />

I want to filter all the links  into a list as:
['http://example.com/2013/01/problem1.html', 'http://example.com/2013/02/problem2.html']

How to do it using Python Regular Expression?

If I want to filter all the links into a dictionary as: 
['http://example.com/2013/01/problem1.html':'Problem No-1', 'http://example.com/2013/02/problem2.html ':'Problem No-2',]

How do I do it? 		 	   		  


More information about the Tutor mailing list