2009/8/3 Victor Subervi <victorsube...@gmail.com>: -> Hi; -> How do I search and replace something like this: > aLine = re.sub('[<]?[p]?[>]?<font size="h' + str(x) + '"[ > a-zA-Z0-9"\'=:]*>[<]?[b]?[>]?', '<h' + str(x) + '>', aLine) > where RE *only* looks for the possibility of "<p>" at the beginning of the > string; that is, not the individual components as I have it coded above, but > the entire 3-character block? > TIA, > Victor
I'm not sure I totally understand your problem, try this: aLine = re.sub(r'(?:<p>)?<font size="h{0}"[^>]*>(?:<b>)'.format(str(x)), '<h' + str(x) + '>', aLine) tiefeng wu 2009-08-03 -- http://mail.python.org/mailman/listinfo/python-list