我是正则表达式的新手——我在 C++ 中使用 Poco 从字符串中提取 IP 地址并(尝试)将所有 IP 匹配项放入字符串向量中:
string result = tcpClient.receiveRaw();
RegularExpression re("\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b");
RegularExpression::MatchVec matches;
re.match(result, 0, matches);
IPlist = result.substr(matches[1].offset, matches[1].length);
我不认为最后一行是正确的(不确定它是如何工作的)我正在尝试从该初始字符串中提取所有 IP 地址并将它们添加到字符串向量中。