Pagini recente » Cod sursa (job #878459) | Cod sursa (job #3129697) | Cod sursa (job #2608033) | Cod sursa (job #2351767) | Cod sursa (job #2322198)
/*
* Software sellers want to divide the users and conquer them, making each
* user agree not to share with others.
* - Richard Stallman
*/
#include <iostream>
#include <fstream>
#include <regex>
int main()
{
std::ifstream fin("strmatch.in");
std::string pattern;
std::string text;
fin >> pattern >> text;
auto r = std::regex{"(?=(" + pattern + "))."};
std::sregex_iterator next{text.cbegin(), text.cend(), r};
std::sregex_iterator end;
std::vector<long> positions;
while (next != end && positions.size() < 1000)
{
std::smatch match = *next;
positions.push_back(match.position());
next++;
}
std::ofstream fout("strmatch.out");
fout << positions.size() << std::endl;
for(long pos: positions)
fout << pos << " ";
return 0;
}