Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Remove the first few(or any amount really) of letters in a string

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


alexnbryan at gmail

Aug 8, 2008, 7:52 PM

Post #1 of 2 (44 views)
Permalink
Remove the first few(or any amount really) of letters in a string

Lets say I've got a stirng:

blah This is my string blah

I want to get rid of the blah's but keep the "This is my string." I know you
can do this with a for loop, but that is messy and a pain. So does anyone
have any suggestions on how to do this?
--
View this message in context: http://www.nabble.com/Remove-the-first-few%28or-any-amount-really%29-of-letters-in-a-string-tp18901736p18901736.html
Sent from the Python - python-list mailing list archive at Nabble.com.

--
http://mail.python.org/mailman/listinfo/python-list


tjreedy at udel

Aug 8, 2008, 7:58 PM

Post #2 of 2 (40 views)
Permalink
Re: Remove the first few(or any amount really) of letters in a string [In reply to]

Alexnb wrote:
> Lets say I've got a stirng:
>
> blah This is my string blah
>
> I want to get rid of the blah's but keep the "This is my string." I know you
> can do this with a for loop, but that is messy and a pain. So does anyone
> have any suggestions on how to do this?

Strings are immutable. Just slice out what you want.
IDLE 3.0b2
>>> "blah This is what I want. blah blah"[5:25]
'This is what I want.'

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.