Re: Problem with re module

2011-03-22 Thread Ethan Furman
John Harrington wrote: Here's a script that illustrates the problem. Any help would be appreciated!: #BEGIN SCRIPT import re outlist = [] myfile = "raw.tex" fin = open(myfile, "r") lineList = fin.readlines() fin.close() for i in range(0,len(lineList)): lineList[i]=re.sub(r'(\\begin{do

Re: Problem with re module

2011-03-22 Thread John Harrington
On Mar 22, 12:07 pm, Benjamin Kaplan wrote: > On Tue, Mar 22, 2011 at 2:40 PM, John Harrington > > > > wrote: > > On Mar 22, 11:16 am, John Bokma wrote: > >> John Harrington writes: > >> > I'm trying to use the following substitution, > > >> >      lineList[i]=re.sub(r'(\\begin{document})([^$])

Re: Problem with re module

2011-03-22 Thread Benjamin Kaplan
On Tue, Mar 22, 2011 at 2:40 PM, John Harrington wrote: > On Mar 22, 11:16 am, John Bokma wrote: >> John Harrington writes: >> > I'm trying to use the following substitution, >> >> >      lineList[i]=re.sub(r'(\\begin{document})([^$])',r'\1\n\n >> > \2',lineList[i]) >> >> > I intend this to matc

Re: Problem with re module

2011-03-22 Thread John Harrington
On Mar 22, 11:16 am, John Bokma wrote: > John Harrington writes: > > I'm trying to use the following substitution, > > >      lineList[i]=re.sub(r'(\\begin{document})([^$])',r'\1\n\n > > \2',lineList[i]) > > > I intend this to match any string "\begin{document}" that doesn't end > > in a line end

Re: Problem with re module

2011-03-22 Thread Peter Otten
John Harrington wrote: > I'm trying to use the following substitution, > > lineList[i]=re.sub(r'(\\begin{document})([^$])',r'\1\n\n > \2',lineList[i]) > > I intend this to match any string "\begin{document}" that doesn't end > in a line ending. If there's no line ending, then, I want to pl

Re: Problem with re module

2011-03-22 Thread John Bokma
John Harrington writes: > I'm trying to use the following substitution, > > lineList[i]=re.sub(r'(\\begin{document})([^$])',r'\1\n\n > \2',lineList[i]) > > I intend this to match any string "\begin{document}" that doesn't end > in a line ending. If there's no line ending, then, I want to pl

Problem with re module

2011-03-22 Thread John Harrington
I'm trying to use the following substitution, lineList[i]=re.sub(r'(\\begin{document})([^$])',r'\1\n\n \2',lineList[i]) I intend this to match any string "\begin{document}" that doesn't end in a line ending. If there's no line ending, then, I want to place two carriage returns between the s