How can i get the specific part of text
Solution 1:
The standard library includes regex.
You could use something close to:
std::string find_ip(const std::string& line) {
std::regex rx{ "\\d+\\.\\d+\\.\\d+\\.\\d+" };
std::smatch ip;
if (std::regex_search(line, ip, rx)) {
return ip.str();
}
return "";
}
Applied to any line from your example, this consistently returns the string 192.168.4.163
.