Boost logo

Boost Users :

Subject: Re: [Boost-users] [Q] string alg to remove spaces
From: Alex MDC (alex.mdc_at_[hidden])
Date: 2009-03-27 05:42:19


2009/3/27 V S P <toreason_at_[hidden]>

> Looking at string algorithms
> and cannot figure what combination of them I need to
>
> remove all, but one spaces between words in a string
> so that
> "1 2 3" becomes "1 2 3"
>

Sounds like you might need a regular expression to find sequences of
multiple spaces.
The algorithms "replace_all_regex" or "replace_all_regex_copy" should do
what you want.

e.g.
string input = "1 2 3";
string output = replace_all_regex_copy(input, regex(" +"), " "); // output
should be "1 2 3"

where " +" is a regular expression to find sequences of 1 or more spaces.

Regards

Alex



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net