stripping a string

Bob Gailer bgailer at alum.rpi.edu
Sat Sep 13 18:15:06 EDT 2003


At 02:51 PM 9/13/2003, 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.

import re
result = re.findall(r'(\D*)\d*',  source)[0]

will remove any number of trailing digits.

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030913/8bf063fa/attachment.html>
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003


More information about the Python-list mailing list