string methods (warning, newbie)

Discussion in 'Python' started by anthonyberet, Feb 27, 2005.

  1. anthonyberet

    anthonyberet Guest

    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?
     
    anthonyberet, Feb 27, 2005
    #1
    1. Advertising

  2. anthonyberet

    anthonyberet Guest

    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?
     
    anthonyberet, Feb 27, 2005
    #2
    1. Advertising

  3. anthonyberet

    Peter Hansen Guest

    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
     
    Peter Hansen, Feb 27, 2005
    #3
  4. anthonyberet

    Terry Reedy Guest

    "anthonyberet" <> wrote in message
    news:...
    > 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
     
    Terry Reedy, Feb 27, 2005
    #4
    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. Pete Becker
    Replies:
    0
    Views:
    1,399
    Pete Becker
    Feb 10, 2005
  2. Nick Coghlan

    Re: string methods (warning, newbie)

    Nick Coghlan, Feb 27, 2005, in forum: Python
    Replies:
    3
    Views:
    269
    Christos TZOTZIOY Georgiou
    Feb 28, 2005
  3. B. Williams

    warning C4267 and warning C4996

    B. Williams, Oct 26, 2006, in forum: C++
    Replies:
    17
    Views:
    2,661
  4. WARNING! Prosoftstore.com is a SCAM! WARNING!

    , Jul 8, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    341
  5. Kenneth McDonald
    Replies:
    5
    Views:
    355
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page