Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <regex>
- using namespace std;
- int main()
- {
- ofstream foutput("output.txt");
- ifstream finput("input.txt");
- std::string str;
- getline(finput, str);
- str.insert(0, " "); str.insert(str.length(), " ");
- std::regex regular("( he | He )"); //Before "he" there should be no letters [^a-z], can be a space ( ?), after "he" there should be no letters [^a-z], but can be a space ( ?)
- str = regex_replace(str.c_str(), regular, " George ");
- for (int i = 1; i < str.length()-1; i++)
- {
- foutput << str[i];
- }
- finput.close();
- foutput.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement