65,186
社区成员




std::string str = "port 1-100, 2-200, 5-500";
std::regex reg("port\\s?((\\d+\\s*-\\s*\\d+)[,|\\s]*)+");
std::smatch match_result;
bool matched = std::regex_match(str, match_result, reg);
for (int i = 0; i < match_result.size(); ++i) {
std::cout << match_result[i] << std::endl;
}