a little help with trimming strings
Hi, Is it possible using the trim() family of functions to remove not just white space, but some substring from the right of a string? For example, if I want to remove commas from the right: string str = "whatever,"; TrimRight(str, ","); // str == "whatever" now. or a full string to trim: string str = "hello world"; TrimRight(str, "world"); // str == "hello "; I could write these simple functions myself but am wondering if boost can do that already, Thanks, Mark
http://www.boost.org/doc/html/string_algo/reference.html#header.boost.algori...
http://engineering.meta-comm.com/resources/cs-win32_metacomm/doc/html/string...
On 9/15/07, Mark Wyszomierski
Hi,
Is it possible using the trim() family of functions to remove not just white space, but some substring from the right of a string? For example, if I want to remove commas from the right:
string str = "whatever,"; TrimRight(str, ","); // str == "whatever" now.
or a full string to trim:
string str = "hello world"; TrimRight(str, "world"); // str == "hello ";
I could write these simple functions myself but am wondering if boost can do that already,
Thanks, Mark _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Sat, 15 Sep 2007 10:50:20 -0400
"Mark Wyszomierski"
Hi,
Is it possible using the trim() family of functions to remove not just white space, but some substring from the right of a string? For example, if I want to remove commas from the right:
string str = "whatever,"; TrimRight(str, ","); // str == "whatever" now.
or a full string to trim:
string str = "hello world"; TrimRight(str, "world"); // str == "hello ";
I could write these simple functions myself but am wondering if boost
Maybe it is "erase_last" what you are looking for:
#include
Thanks guys, works perfectly,
Mark
On 9/15/07, raulh39@ya.com
On Sat, 15 Sep 2007 10:50:20 -0400 "Mark Wyszomierski"
wrote: Hi,
Is it possible using the trim() family of functions to remove not just white space, but some substring from the right of a string? For example, if I want to remove commas from the right:
string str = "whatever,"; TrimRight(str, ","); // str == "whatever" now.
or a full string to trim:
string str = "hello world"; TrimRight(str, "world"); // str == "hello ";
I could write these simple functions myself but am wondering if boost
Maybe it is "erase_last" what you are looking for:
#include
using namespace algorithm;
string str = "hello world"; erase_last(str,"world"); // str == "hello "
HTH. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
chun ping wang
-
Mark Wyszomierski
-
raulh39@ya.com