Suggestions for how to approach this problem?

John Salerno johnjsal at NOSPAMgmail.com
Tue May 8 15:05:18 EDT 2007


I figured I might give myself a little project to make my life at work 
easier, so here's what I want to do:

I have a large list of publication citations that are numbered. The 
numbers are simply typed in with the rest of the text. What I want to do 
is remove the numbers and then put bullets instead. Now, this alone 
would be easy enough, with a little Python and a little work by hand, 
but the real issue is that because of the way these citations were 
typed, there are often line breaks at the end of each line -- in other 
words, the person didn't just let the line flow to the next line, they 
manually pressed Enter. So inserting bullets at this point would put a 
bullet at each line break.

So I need to remove the line breaks too, but of course not *all* of them 
because each reference still needs a line break between it. So I'm 
hoping I could get an idea or two for approaching this. I figure regular 
expressions will be needed, and maybe it would be good to remove the 
line breaks first and *not* remove a line break that comes before the 
numbers (because that would be the proper place for one), and then 
finally remove the numbers.

Thanks.



More information about the Python-list mailing list