boost::regex re("get.+");
例子。
#include <iostream>
#include <string>
#include <boost/regex.hpp>
#include <vector>
#include <algorithm>
int main()
{
std::vector<std::string> vec =
{
"com::sun::star:getMethodName",
"com:sun:star::SetStatus",
"com::sun::star::getMessage"
};
boost::regex re("get.+");
std::for_each(vec.begin(), vec.end(), [&re](const std::string& s)
{
boost::smatch match;
if (boost::regex_search(s, match, re))
{
std::cout << "Matched" << std::endl;
std::cout << match << std::endl;
}
});
}
http://liveworkspace.org/code/7d47ad340c497f7107f0890b62ffa609