stripping a string

L

Leeds, Mark

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
 
U

Uwe Schmitt

Leeds said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top