Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > string methods (warning, newbie)

Reply
Thread Tools

string methods (warning, newbie)

 
 
anthonyberet
Guest
Posts: n/a
 
      02-27-2005
Is there a string mething to return only the alpha characters of a string?
eg 'The Beatles - help - 03 - Ticket to ride', would be
'TheBeatlesTickettoride'

If not then how best to approach this?
I have some complicated plan to cut the string into individual
characters and then concatenate a new string with the ones that return
true with the .isalpha string method.

Is there an easier way?
 
Reply With Quote
 
 
 
 
anthonyberet
Guest
Posts: n/a
 
      02-27-2005
anthonyberet wrote:
> Is there a string mething [method] to return only the alpha characters of a string?
> eg 'The Beatles - help - 03 - Ticket to ride', would be
> 'TheBeatlesTickettoride'
>

erm, no it wouldn't, it would be 'TheBeatleshelpTickettoride', but you
get me, I am sure.

> If not then how best to approach this?
> I have some complicated plan to cut the string into individual
> characters and then concatenate a new string with the ones that return
> true with the .isalpha string method.
>
> Is there an easier way?

 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      02-27-2005
anthonyberet wrote:
> Is there a string mething to return only the alpha characters of a string?
> eg 'The Beatles - help - 03 - Ticket to ride', would be
> 'TheBeatlesTickettoride'
>
> If not then how best to approach this?
> I have some complicated plan to cut the string into individual
> characters and then concatenate a new string with the ones that return
> true with the .isalpha string method.
>
> Is there an easier way?


Look into the string module's "translate" function. It will
do this for you fairly easily.

-Peter
 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      02-27-2005

"anthonyberet" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there a string mething to return only the alpha characters of a
> string?
> eg 'The Beatles - help - 03 - Ticket to ride', would be
> 'TheBeatlesTickettoride'


I believe you can do this with string.translate (string module, not str())

tjr



 
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
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
Top-Up Methods - Finarea (Voipcheap, internetcalls, etc.) et. al., VOIP Services Question - Top-up Methods News Reader UK VOIP 0 04-10-2006 02:41 PM
Why Petshop Changed all static methods to instance methods when upgrading from version 3.0 to version 3.1? Neo ASP .Net 1 01-07-2005 01:46 AM
Derived methods hiding inherited methods Tron Thomas C++ 10 11-10-2004 09:32 AM
Re: Templates and friends and template methods with private methods. Buster Copley C++ 5 07-07-2003 12:50 AM



Advertisments