[Tutor] reg expression substitution question
Scott Ralph Comboni
scott@zenplex.com
06 Apr 2001 14:53:46 -0400
I have used perl -p -i -e 's/someName/replaceName/g' <file name>. Is
there a way to do this type of substitution with the re module?
I have tried various ways but all I can come up with is this>>
file = open('config.h').read()
newfile = open('config.h.new','w')
s = re.sub('8192', '32768', file)
newfile.write(s)
newfile.close()
Is there a way I can just read and write to the same file?
Thanks Scott
--
Scott Ralph Comboni
http://www.zenplex.com
http://www.zenplex.org
http://tambora.zenplex.org