RE: Deleting specific characters from a string

Discussion in 'Python' started by Michael Chermside, Jul 10, 2003.

  1. Paul Rudin writes:
    > I haven't been following this thread closely but isn't a regexp the
    > obvious way to do this?


    No. The one thing that's QUITE clear is that there are multiple ways
    to do this, some of which are more readable than others, but there's
    no "one obvious way".

    > I'd expect it to be faster than your solution
    > - particularly on large input (although I haven't actually
    > tried).


    Hmm... I doubt it. I'd expect the translate() version to be the
    fastest, with multiple string.remove()'s being competative when
    the number of different characters to be removed is small. RE's
    are NOT renown for their speed when doing simple character
    replacement, deletion or insertion on strings. But _I_ haven't
    timed it either, so I'm going to shut up now.

    -- Michael Chermside


    -------------------------------------------------
    This mail sent through IMP: http://horde.org/imp/
     
    Michael Chermside, Jul 10, 2003
    #1
    1. Advertising

  2. Michael Chermside

    Paul Rudin Guest

    >>>>> "Michael" == Michael Chermside <> writes:

    > Paul Rudin writes:



    >> I'd expect it to be faster than your solution - particularly on
    >> large input (although I haven't actually tried).


    > Hmm... I doubt it. I'd expect the translate() version to be the
    > fastest, with multiple string.remove()'s being competative when
    > the number of different characters to be removed is small. RE's
    > are NOT renown for their speed when doing simple character
    > replacement, deletion or insertion on strings.


    My comparison was with one particular solution, not all solutions
    mentioned. Still I was previosuly unaware of the existence of
    translate... so thanks for mentioning it.


    > But _I_ haven't timed it either, so I'm going to shut up now.


    Me too :)
     
    Paul Rudin, Jul 10, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry
    Replies:
    2
    Views:
    2,526
    Jerry
    Jan 13, 2005
  2. Behrang Dadsetan

    Deleting specific characters from a string

    Behrang Dadsetan, Jul 9, 2003, in forum: Python
    Replies:
    17
    Views:
    747
    Bengt Richter
    Jul 11, 2003
  3. Harry Barker
    Replies:
    2
    Views:
    529
    Alf P. Steinbach
    Apr 19, 2006
  4. Aldric Giacomoni
    Replies:
    0
    Views:
    113
    Aldric Giacomoni
    Feb 18, 2009
  5. crea
    Replies:
    2
    Views:
    423
    Nobody
    Dec 28, 2012
Loading...

Share This Page