Re: Removing a character from a string
- From: "Andrew Chalk" <achalk@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 17 May 2007 13:15:27 -0500
Thansk! That's where they hid it!
- A
"Igor Tandetnik" <itandetnik@xxxxxxxx> wrote in message
news:OvQJq2KmHHA.4688@xxxxxxxxxxxxxxxxxxxxxxx
Andrew Chalk <achalk@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Am I missing something? std::string() doesn't seem to have a member to
remove all occurances of a character from a string.
For example, given:
s = "encyclopedia"
s.remove('e')
yields:
"ncyclopdia"
What is the best way to do this?
#include <algorithm>
s.erase(std::remove(s.begin(), s.end(), 'e'), s.end());
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: Removing a character from a string
- From: duyuor
- Re: Removing a character from a string
- References:
- Removing a character from a string
- From: Andrew Chalk
- Re: Removing a character from a string
- From: Igor Tandetnik
- Removing a character from a string
- Prev by Date: Re: Removing a character from a string
- Next by Date: Re: Removing a character from a string
- Previous by thread: Re: Removing a character from a string
- Next by thread: Re: Removing a character from a string
- Index(es):
Relevant Pages
|
Loading