SilentFlame

reHTml

Jun 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include <sstream>
  2. #include <string>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <typeinfo>
  6. using namespace std;
  7.  
  8.  
  9.  
  10. string convertRehtml(string str){
  11. int len = str.length();
  12. int flag =0;
  13. string temp_str;
  14. string finalStr = "";
  15. int i = 0;
  16. cout << "in" ;
  17. while(i+1 < len){
  18. if(str[i]=='[' && str[i+1]=='<'){
  19. i++;
  20. while(str[i]!='>' && str[i+1]!=']'){
  21. finalStr += str[i];
  22. i++;
  23. }
  24. finalStr += str[i];
  25. i++;
  26. }
  27. else if(str[i]=='[' && str[i+1]=='{'){
  28. i+=2;
  29. while(str[i]!='}' && str[i+1]!=']'){
  30. temp_str = "";
  31. flag = 0;
  32. if(str[i]=='<'){
  33. finalStr += str[i+1];
  34. i++;
  35. while(str[i]!=' ' && flag == 0){
  36. if(str[i]== ' '){
  37. flag = 1;
  38. break;
  39. }
  40. temp_str += str[i];
  41. finalStr += str[i];
  42. i++;
  43. }
  44. cout << temp_str;
  45. finalStr += temp_str;
  46. }
  47. }
  48. }
  49. else if(str[i]=='\n'){
  50. finalStr += str[i];
  51. finalStr += " ENTER HOYA JI ";
  52. i++;
  53. }
  54. else{
  55. finalStr += str[i];
  56. i++;
  57. }
  58. }
  59. return finalStr;
  60. }
  61.  
  62.  
  63. int main() {
  64.  
  65. ifstream myfile("test.txt");
  66. string line;
  67. string final;
  68.  
  69. if(myfile.is_open()){
  70. while(getline(myfile, line)){
  71. cout << line << endl;// Process line
  72. final += line;
  73. final += "\n";
  74. }
  75. myfile.close();
  76. }
  77.  
  78. cout << typeid(final).name() << endl;
  79. cout << typeid(line).name() << endl;
  80.  
  81. cout << convertRehtml(final) << endl;
  82. return 0;
  83. }
Add Comment
Please, Sign In to add comment