15inline std::vector<std::string>
findFromFile(
const std::string &filePath,
const std::string &pattern,
16 std::string &lastWord)
18 const std::regex regExp(pattern);
19 std::ifstream inFile(filePath);
20 std::vector<std::string> matchedLines;
23 while (getline(inFile, readLine))
25 if (std::regex_search(readLine, regExp))
27 matchedLines.push_back(readLine);
31 if (!matchedLines.empty())
33 auto pos = matchedLines.front().find_last_of(
' ');
34 if (pos != std::string::npos && pos != matchedLines.front().size())
36 lastWord = matchedLines.front().substr(pos + 1);