Hejka sluchajcie ostatnio tutaj zamiesciłem swój problem z "narzędziem replace" mianowicie chcialbym to przerobić żeby używalo std::regex
#include <iostream>
#include <fstream>
int main()
{
std::string::size_type pos;
std::string oldWord;
std::string newWord;
std::cin >> oldWord;
std::cin >> newWord;
std::ifstream openfile("test");
std::string tmp;
while (getline(openfile, tmp))
{
while ((pos = tmp.find(oldWord, pos)) != std::string::npos)
{
tmp.replace(pos, oldWord.length(), newWord);
pos += newWord.length();
}
}
std::cout << " Zdanie: " << tmp << std::endl;
std::cout << "Slowo do zamiany: " << oldWord << std::endl;
std::cout << " Do zamiany na: " << newWord << std::endl;
std::cout << " Find oldWord: " << tmp.find(oldWord) << std::endl;
std::cout << " Length oldWord: " << oldWord.length() << std::endl;
while ((tmp.find(oldWord)) != std::string::npos)
{
tmp.replace(tmp.find(oldWord), oldWord.length(), newWord);
}
std::cout << " Po Replace: " << tmp;
return 0;
}
"Rozszerz program tak,
aby mógł podmieniać wystąpienia
pasujące do wyrażenia regularnego. Zastosuj std::regex."
Zbytnio nie czaje założenia jest ktos w stanie pomóc mi to napisać bądź wytlumaczyc ?