Boost logo

Boost Users :

From: Pavol Droba (droba_at_[hidden])
Date: 2005-01-19 16:29:25


On Wed, Jan 19, 2005 at 03:09:57PM -0500, Jeff Flinn wrote:
> Am I required to use regex_finder to replace repeated chars with a single instance? I'm trying to cleanup a string for use with filesystem::path, for example:
>
> C:\\abc///def\\ghi => C:\abc\def\ghi
>
> There may be mixed forward and back-slashes. These are from environment variables that apparently are required by our use of NutCracker to support legacy apps under windows.
>
> If I need to use regex_finder what are the benefits of the string_algo versus just using the regex library?
>

Actualy you can do it without regex. You need to use token_finder and find_format.

<code>

string strPath=find_format_all_copy(
   "C:\\abc\\def//ghi",
   token_finder(is_any_of("\\/"), token_compress_on),
   const_formatter("\\"));

//strPath == C:\abc\def\ghi

</code>

Using the regex_finder is also possible, but you will not gain much more compared to using regex library directly.


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