Re: [Boost-users] [Regex] Replace algorithm

Hi,
The iostreams library has a basic_regex_filter that will do this job.
See
http://www.boost.org/libs/iostreams/doc/classes/regex_filter.html
or in context
http://www.boost.org/libs/iostreams/doc/index.html
4. Reference -> 4.2 Classes -> basic_regex_filter
The following ctor is the one you probably want
basic_regex_filter( const basic_regex
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]On Behalf Of Johan Nilsson Sent: Monday, 22 May 2006 7:53 PM To: boost-users@lists.boost.org Subject: [Boost-users] [Regex] Replace algorithm
Hi,
I'd like to replace all parts of a string with the results of calling a function, passing the match as a parameter. Some pseudo-code:
--- std::string replacer(smatch& s) { return std::getenv(s[1].c_str()); }
std::string const input = "This is ${USER} on ${HOST}"; boost::regex const re("\\$\\{([^\\}]+)\\}"); std::string result = boost::regex_replace(input, re, boost::bind(&replacer));
assert("This is Me on MyWorkstation" == result); ---
(I'm sure there are errors above, but I hope you get the general idea).
Any easy way to do something similar?
// Johan
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (1)
-
Andrew McDonald