|
Boost Users : |
Subject: Re: [Boost-users] [string_algo] replace string with tokens
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-06-03 13:23:11
On Wed, Jun 3, 2009 at 1:58 AM, Boris Schaeling <boris_at_[hidden]> wrote:
> On Sun, 31 May 2009 10:15:22 +0200, Michael Schuster <schuster_at_[hidden]>
> wrote:
>
>> Hello,
>> I'm new to string_algo and have the following problem:
>>
>> I have string like
>>
>> a+3*sin(b)
>>
>> and want to replace a by a different string e.g. Alpha and b by Beta and
>> sin
>> by cos so that
>>
>> Alpha+3*cos(Beta)
>>
>> is the result.
>>
>> So tokens would be "+*()"
>>
>> The replace command works with spaces, but I think this should be possible
>> with string_algo, too?
>
> I'm not sure what you mean with 'replace command'.
> boost::algorithm::replace_all() simply replaces a substring with another. If
> you mean boost::algorithm::split() you can pass a predicate as the third
> parameter (boost::algorithm::is_punct() might help).
For what you are doing, perhaps regex_replace in Boost.Xpressive might
be more useful?
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