Boost.Xpressive でセマンティックアクション
こんなことが出来るみたい。
[ソース]
#include <boost/xpressive/xpressive.hpp> #include <boost/xpressive/regex_actions.hpp> #include <string> int main(){ namespace x = boost::xpressive; using x::_; std::string result; x::sregex regex = "(" >> ((x::s1 = -*_)[x::ref(result) = x::s1]) >> ")"; std::string const source = "(mami)"; if( x::regex_search(source, regex) ){ std::cout << result << std::endl; } return 0; }
[boost]
- ver 1.49.0