'string'.strip(chars)-like function that removes from the middle?

Ethan Furman ethan at stoneleaf.us
Tue Jun 17 15:42:20 EDT 2008


Ethan Furman wrote:
> Greetings.
> 
> The strip() method of strings works from both ends towards the middle.
> Is there a simple, built-in way to remove several characters from a 
> string no matter their location? (besides .replace() ;)
> 
> For example:
> .strip --> 'www.example.com'.strip('cmowz.')
> 'example'
> .??? --> --- 'www.example.com'.strip('cmowz.')
> 'exaple'

Thanks for all the ideas!
--
Ethan



More information about the Python-list mailing list