Closed Blackflame576 closed 1 year ago
#include <iostream> #include <fstream> #include <regex> int main() { std::ifstream stream("/etc/os-release"); std::string line; std::regex nameRegex("^NAME=\"(.*?)\"$"); std::smatch match; std::string name; while (std::getline(stream, line)) { if (std::regex_search(line, match, nameRegex)) { name = match[1].str(); break; } } std::cout << name << std::endl; return 0; }