On 23 Jan 2006 07:18:13 -0800, Pankaj <[EMAIL PROTECTED]> wrote: > > [snip] >What i tried in python was:: > >f = open( "./1.c", "r") >fNew = open( "./1_new.c", "w") >for l in f: > print l > lineno = lineno + 1 > strToFind = "for\((.*)\;(.*)" > > ## For Converting int to string, i.e. line no. to string > lineNoClone = lineno > > pattern = "printf(\"" + str( lineNoClone) + "\")," > > print pattern > > strToReplace = "for\(" + pattern + "\1\;" > > fNew.write( l.replace( strToFind, strToReplace) ) > > print l > >fNew.close() >
str.replace() does not support regular expressions. Take a look at the re module. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list