Replacing Periods with Backspaces

Aahz aahz at pythoncraft.com
Fri Apr 9 11:22:11 EDT 2010


In article <8404fac9-06c7-4555-93af-c78f5e01d730 at j21g2000yqh.googlegroups.com>,
Booter  <colo.avs96 at gmail.com> wrote:
>
>I am trying to replace a series of periods in a sting with backspaces
>that way I can easily parse information from a Windows command.  the
>current statement I have for this is
>
>capture = re.sub('\.*', '\b', capture)

What's wrong with 

capture = capture.replace('.', '\b')

That will be much faster.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"...string iteration isn't about treating strings as sequences of strings, 
it's about treating strings as sequences of characters.  The fact that
characters are also strings is the reason we have problems, but characters 
are strings for other good reasons."  --Aahz



More information about the Python-list mailing list