
llwaeva@21cn.com wrote:
Hi there, boost:regex is powerful in string replacing. I am working with a complicate case which need a faster method in replacing substring. Here is my problem.
I have a big string contains some pattern %K{xxx}, where xxx is a filename which may vary from place to place. e.g.
Any better idea for my problem?
I suggest you enumerate through the regular expression matches and for each match: 1) Copy everything from the end of the last match (or the start of the string) to the new buffer. 2) Read the filename, and copy the contents of the filename to the new string. 3) Loop and continue. The code would be almost exactly the same as the internals of regex_replace if that helps. You could also improve matters slightly by calling std::string::reserve on the new string before starting. John.