#include #include #include #include #include #include bool parseBusName(const std::string& busName, char busOpen, char busDivide, char busClose, std::string& baseName, size_t& firstIndex, size_t& secondIndex) { boost::regex regularExpressionBus ( //Name - anything but bus_open "^([^" + std::string(1, busOpen) + "]+)" // bus_open + std::string(1, busOpen) + //End bus index "([0-9]+)" //Colon + std::string(1, busDivide) + //Start bus index "([0-9]+)" //bus_close + std::string(1, busClose), boost::regex::extended); boost::cmatch what; if(!regex_match(busName.c_str(), what, regularExpressionBus)) return false; std::cerr << what.size() << " >" << what[1] << "< >" << what[2] << "< >" << what[3] << "<" << std::endl; baseName = what[1]; firstIndex = boost::lexical_cast(what[2]); secondIndex = boost::lexical_cast(what[3]); return true; } int main() { char busOpen = '<'; char busDivide = ':'; char busClose = '>'; std::string baseName; size_t first, second; parseBusName("abc<3:1>", busOpen, busDivide, busClose, baseName, first, second); }