Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <regex>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.  
  11.     ofstream foutput("output.txt");
  12.     ifstream finput("input.txt");
  13.     std::string str;
  14.     getline(finput, str);
  15.     str.insert(0, " "); str.insert(str.length(), " ");
  16.     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 ( ?)
  17.  
  18.  
  19.     str = regex_replace(str.c_str(), regular, " George ");
  20.  
  21.     for (int i = 1; i < str.length()-1; i++)
  22.     {
  23.         foutput << str[i];
  24.     }
  25.  
  26.  
  27.     finput.close();
  28.     foutput.close();
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement