stripping a string

Discussion in 'Python' started by Leeds, Mark, Sep 13, 2003.

  1. Leeds, Mark

    Leeds, Mark Guest

    hello : i am very much a python novice because
    I only use it for preprocessing data that
    i send into another language called Splus.

    I have the following problem that
    I have spent a lot of time on but I
    can't figure out.

    I have a string called tickerstring
    that might be

    "ANL LN32"

    and i want to get rid of the digit piece.
    so that i get "ANL LN"

    i can't just take off the last two charcters
    because the string could also be

    "ANL LN3" for example.

    thanks to anyone who could explain
    how to do this ?

    mark
     
    Leeds, Mark, Sep 13, 2003
    #1
    1. Advertising

  2. Leeds, Mark

    Uwe Schmitt Guest

    Leeds, Mark <> wrote:
    hello : i am very much a python novice because
    > I only use it for preprocessing data that
    > i send into another language called Splus.
    >
    > I have the following problem that
    > I have spent a lot of time on but I
    > can't figure out.
    >
    > I have a string called tickerstring
    > that might be
    >
    > "ANL LN32"
    >
    > and i want to get rid of the digit piece.
    > so that i get "ANL LN"
    >
    > i can't just take off the last two charcters
    > because the string could also be
    >
    > "ANL LN3" for example.
    >
    > thanks to anyone who could explain
    > how to do this ?
    >


    If the numbers only occur at the end of the string:


    a = "ANL LN32"
    print a.rstrip("0123456789")

    Greetings, Uwe.


    --
    Dr. rer. nat. Uwe Schmitt http://www.procoders.net
    "A service to open source is a service to mankind."
     
    Uwe Schmitt, Sep 16, 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. Jeff Epler

    Re: stripping a string

    Jeff Epler, Sep 14, 2003, in forum: Python
    Replies:
    4
    Views:
    366
    Tim Williams
    Sep 16, 2003
  2. joram gemma

    string.lstrip stripping too much?

    joram gemma, May 15, 2005, in forum: Python
    Replies:
    4
    Views:
    397
    M.E.Farmer
    May 16, 2005
  3. orangeDinosaur

    string stripping issues

    orangeDinosaur, Mar 2, 2006, in forum: Python
    Replies:
    7
    Views:
    361
    Larry Bates
    Mar 3, 2006
  4. Edward Elliott

    stripping unwanted chars from string

    Edward Elliott, May 4, 2006, in forum: Python
    Replies:
    7
    Views:
    418
    Alex Martelli
    May 4, 2006
  5. Raj
    Replies:
    7
    Views:
    939
    Joe Wright
    May 11, 2005
Loading...

Share This Page