Jul 14, 2021 at 8:19am
How to fetch text between 2 texts
or end of text with std::regex ?
1 2 3 4 5 6 7 8 9 10 11 12
|
#include <regex>
#include <iostream>
int main()
{
const std::string s = "Ipsum liripsum limsum sapsum nit";
std::regex rgx("liripsum (\\w+) sapsum");
std::smatch match;
if (std::regex_search(s.begin(), s.end(), match, rgx))
std::cout << "match: " << match[1] << '\n';
}
|
Last edited on Jul 14, 2021 at 8:19am
Jul 15, 2021 at 12:18am
Something like:
|
std::regex rgx("liripsum +(\\w+)(?: +sapsum|$)");
|
Last edited on Jul 15, 2021 at 12:22am