That worked. Thank you again :)<br>Victor<br><br><div class="gmail_quote">On Mon, Aug 3, 2009 at 12:13 AM, Gabriel Genellina <span dir="ltr"><<a href="mailto:gagsl-py2@yahoo.com.ar">gagsl-py2@yahoo.com.ar</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">En Sun, 02 Aug 2009 18:22:20 -0300, Victor Subervi <<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a>> escribió:<div>
<div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
How do I search and replace something like this:<br>
aLine = re.sub('[<]?[p]?[>]?<font size="h' + str(x) + '"[<br>
a-zA-Z0-9"\'=:]*>[<]?[b]?[>]?', '<h' + str(x) + '>', aLine)<br>
where RE *only* looks for the possibility of "<p>" at the beginning of the<br>
string; that is, not the individual components as I have it coded above, but<br>
the entire 3-character block?<br>
</blockquote>
<br></div></div>
An example would make it more clear; I think you want to match either "<p><font size=...." or "<font size=....". In other words, "<p>" is optional. Use a normal group or a non-capturing group:<br>

r'(<p>)?<font size="...'<br>
r'(?:<p>)?<font size="...'<br>
<br>
That said, using regular expressions to parse HTML or XML is terribly fragile; I'd use a specific tool (like BeautifulSoup, ElementTree, or lxml)<br>
<br>
-- <br>
Gabriel Genellina<br><font color="#888888">
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>