On 5/24/2011 5:13 PM, Alexander Mingalev wrote:
On 24.05.2011 12:58, Kraus Philipp wrote:
Performance is not my primary aspect. I would like to use a component
that can do this, because the remove only runs one time.
Maybe, Boost.Xpressive will work for you.
Yes, it can. Static xpressive has "symbol tables" (a search trie). You
put all the string into a std::map. It'd look something like this:
#include <string>
#include <iostream>
#include
#include
using namespace boost::xpressive;
int main()
{
std::map number_map;
number_map["one"] = "1";
number_map["two"] = "2";
number_map["three"] = "3";
localstd::string sub;
sregex rx = icase(a1 = number_map)[sub = a1];
std::string input = "This ONE has tWo some thrEE strings";
input = regex_replace(input, rx, sub);
std::cout << input << '\n';
}
The above program displays the following:
This 1 has 2 some 3 strings
It should be pretty quick, too.
--
Eric Niebler
BoostPro Computing
http://www.boostpro.com