Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 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.     std::cmatch result;
  16.     std::regex regular("([^a-z] ?he[^a-z] ?|[^a-z] ?He[^a-z] ?)"); //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.             foutput << regex_replace(str.c_str(), regular, " George ");
  19.  
  20.  
  21.     finput.close();
  22.     foutput.close();
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement