On Tue, 28 Jul 2009 16:12:19 -0700, nickname wrote: > I'm a newbie with python. I am looking to write a regex > program which can take in a piece of text and remove some parts of it > and supply the remaining parts back. > > The input can be something like: > <script>document.write("h" +"e"+ "ll"+ "ooooo"+ " m" +"y"+" n"+"ame"+ > " is "+"21c";)</script> > > The output should be something like > <script>document.write("hellooooo my name is 21c";)</script>
import re r = re.compile(r'"\s*\+\s*"') s = r'''<script>document.write("h" +"e"+ "ll"+ "ooooo"+ " m" +"y"+" n"+"ame"+ " is "+"21c";)</script>''' r.sub('', s) -- http://mail.python.org/mailman/listinfo/python-list