Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50903

Re: Find and Replace Simplification

X-Received by 10.224.36.15 with SMTP id r15mr21610968qad.8.1374241111941; Fri, 19 Jul 2013 06:38:31 -0700 (PDT)
X-Received by 10.182.135.225 with SMTP id pv1mr273718obb.14.1374241111870; Fri, 19 Jul 2013 06:38:31 -0700 (PDT)
Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!u2no23767qao.0!news-out.google.com!dk8ni705qab.0!nntp.google.com!f1no25863qae.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Fri, 19 Jul 2013 06:38:31 -0700 (PDT)
In-Reply-To <mailman.4865.1374240179.3114.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=199.66.119.11; posting-account=ysljugoAAABv5K6R4l-Ri_n20P-CS_NW
NNTP-Posting-Host 199.66.119.11
References <mailman.4865.1374240179.3114.python-list@python.org>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <ec0b6a8b-ea8c-4137-b2a3-931bf401e0bd@googlegroups.com> (permalink)
Subject Re: Find and Replace Simplification
From Novocastrian_Nomad <gregory.j.baker@gmail.com>
Injection-Date Fri, 19 Jul 2013 13:38:31 +0000
Content-Type text/plain; charset=ISO-8859-1
X-Received-Bytes 1616
Xref csiph.com comp.lang.python:50903

Show key headers only | View raw


On Friday, July 19, 2013 7:22:48 AM UTC-6, Devyn Collier Johnson wrote:
> I have some code that I want to simplify. I know that a for-loop would 
> 
> work well, but can I make re.sub perform all of the below tasks at once, 
> or can I write this in a way that is more efficient than using a for-loop?
> 
> DATA = re.sub(',', '', 'DATA')
> DATA = re.sub('\'', '', 'DATA')
> DATA = re.sub('(', '', 'DATA')
> DATA = re.sub(')', '', 'DATA')


Try DATA = re.sub(r'[(,\\)]', '', 'DATA')

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-19 09:22 -0400
  Re: Find and Replace Simplification Novocastrian_Nomad <gregory.j.baker@gmail.com> - 2013-07-19 06:38 -0700
  Re: Find and Replace Simplification John Gordon <gordon@panix.com> - 2013-07-19 14:28 +0000
  Re: Find and Replace Simplification Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-19 16:22 +0000
    Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-19 20:29 +0300
    Re: Find and Replace Simplification Skip Montanaro <skip@pobox.com> - 2013-07-19 13:08 -0500
    Re: Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-19 17:44 -0400
    Re: Find and Replace Simplification Dave Angel <davea@davea.name> - 2013-07-19 18:45 -0400
    Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 12:16 +0100
    Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-20 14:48 +0300
    Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-20 14:57 +0300
    Re: Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 08:41 -0400
    Re: Find and Replace Simplification Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 08:50 -0400
    Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 18:03 +0100
    Re: Find and Replace Simplification Dave Angel <davea@davea.name> - 2013-07-20 14:04 -0400
    Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 19:37 +0100
    Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 19:41 +0100
    Re: Find and Replace Simplification Dave Angel <davea@davea.name> - 2013-07-20 17:56 -0400
    Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-20 23:33 +0100
    Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-21 10:44 +0300
    Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-21 12:29 +0100
    Re: Find and Replace Simplification Serhiy Storchaka <storchaka@gmail.com> - 2013-07-21 15:28 +0300
    Re: Find and Replace Simplification Joshua Landau <joshua@landau.ws> - 2013-07-21 13:49 +0100

csiph-web