Hello everyone,<br><br>&nbsp;&nbsp;&nbsp; Iam new to this mailing list as well as python(uptime-3 weeks).Today I learnt about RE from <a href="http://www.amk.ca/python/howto/regex/%22RE%27s" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.amk.ca/python/howto/regex/</a>.This one was really helpful. I started working out with few examples on my own. The first one was to collect all the HTML tags used in an HTML file. I wrote this code.<br><br>------------------------------
<br>
import re<br>file1=open(raw_input(&quot;\nEnter The path of the HTML file: &quot;),&quot;r&quot;)<br>ans=&quot;&quot;<br>while 1:<br>&nbsp;&nbsp;&nbsp; data=file1.readline()<br>&nbsp;&nbsp;&nbsp; if data==&quot;&quot;:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break<br>&nbsp;&nbsp;&nbsp; ans=ans+data&nbsp;&nbsp;&nbsp; 
<br>&nbsp;&nbsp;&nbsp; <br>ans1=re.sub(r' .*?',&quot;&gt;&quot;,ans)&nbsp; # to make tags such as &lt;link rel..&gt; to &lt;link&gt;rel<br>match=re.findall(r'&lt;[^/]?[a-zA-Z]+.*?&gt;',ans1)<br>print match<br clear="all">---------------------------------
<br><br>I get the output but with tags repeated. I want to display all the tags used in a file ,but no repetitions.Say the output to one of the HTML file I got was : &quot;&lt;html&gt;&lt;link&gt;<span style="font-weight: bold;">
&lt;a&gt;&lt;br&gt;&lt;a&gt;&lt;br&gt;</span>&quot;<br><br>Instead of writing a new 'for,if' loop to filter the repetetive tags from the list, is there something that I can add in the re itself to match the pattern only once?
<br><br>Thank You<br>-- <br>Intercodes<br>