Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Deleting specific characters from a string

Reply
Thread Tools

RE: Deleting specific characters from a string

 
 
Michael Chermside
Guest
Posts: n/a
 
      07-10-2003
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/

 
Reply With Quote
 
 
 
 
Paul Rudin
Guest
Posts: n/a
 
      07-10-2003
>>>>> "Michael" == Michael Chermside <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check first x characters match a specific string Angus C Programming 16 11-18-2010 06:28 AM
Deleting a specific sequence of characters (linebreaks?) from astring Aldric Giacomoni Ruby 0 02-18-2009 03:57 AM
How to delete specific characters from a string? Bazsl Ruby 11 10-12-2007 12:38 PM
XSL count specific characters in string Jerry XML 2 01-13-2005 05:41 PM
Deleting specific characters from a string Behrang Dadsetan Python 17 07-11-2003 02:49 PM



Advertisments