
On Fri, Mar 14, 2008 at 12:42 PM, Eric Niebler <eric@boost-consulting.com> wrote:
Robert Dailey wrote:
An example of a string that I'll be searching is below:
"This string $(variable1) has localized $(var2) text interleaved for no $(reason)"
In the string above, we have 3 variables. Each variable will reference a string in a localization table, which will then be used to replace the variable itself.
It's not be hard to build such a thing using using regex_iterator. Here's some code to get you going...
#include <map> #include <iostream> #include <boost/xpressive/xpressive.hpp> using namespace boost;
<snip>
HTH,
-- Eric Niebler Boost Consulting www.boost-consulting.com
Thank you very much for helping. I wouldn't go as far as to say it isn't hard, because that looks very hard IMHO. I was hoping for something a little more intuitive and built-in. Instead of going through all of that work I will probably first try to find a different third party regular expression library that can automate this task for me so that I can keep my code a little cleaner and focus on the actual task. I know that other regex libraries in other languages provide such a feature. Perhaps in the future Boost.Xpressive can be extended to provide this behavior. You could simply create a version of regex_replace() that takes a functor as the replacement instead of a string. Again, I appreciate the help and I will use your code example as a reference in the future if I ever decide to come back to this.