Boost logo

Boost Users :

Subject: [Boost-users] best tool in Boost for (massive) string replacement?
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-09-23 18:11:20


With all the tools available in Boost and coming from a different
backgroup is hard for me to choose what is the best tool in Boost to
do a massive string replacement.

The problem I have is the following, I have a map of replaced and
replacing strings

std::map<string,string> rep;
rep["\\alpha"] = "a";
rep["\\beta"] = "b";
...

let's say about 100 of these. And I have an input/output file (few
thousand lines) were I would like to do all this replacements. What is
the best tool in boost to do this,
Spirit, Regex, tokenizer, StringAlgorithm?

My only approach so far is Regex and the implementation is very crude.
I read the file line by line and do a loop over the replacement keys
for each line. It is not even exploiting the fact that I have a map of
replacements (compared to an array of replacements). It seems very
slow.

(Yes, it is like a 'sed' unix command replacement but with hundreds of
replacement strings)

Thank you,
Alfredo


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