Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <windows.h>
  5. #include <set>
  6. #include <iomanip>
  7. #include <regex>
  8. #include <stdio.h>
  9.  
  10. using namespace std;
  11. int main()
  12. {
  13.     bool correct;
  14.     bool allcorrect = false;
  15.     int line = 0;
  16.     //Regular Expressions [\\s\\w!?.,] - slovo bogy, help ! ? Me.
  17.     std::regex RegularText("([\\s\\w!?.,]+)");
  18.     std::regex RegularHadings("([#]{1,6} [\\s\\w!?.,]*)");
  19.     std::regex ItalicText1("(([\\s\\w!?.,]*[*]([\\s\\w!?.,]*)[*]([\\s\\w!?.,]*))+)"); //ab? c, qw *as? fa! q,s!* as? D, q! s.
  20.     std::regex ItalicText2("(([\\s\\w!?.,]*[_]([\\s\\w!?.,]*)[_]([\\s\\w!?.,]*))+)"); //ab? c, qw _as? fa! q,s!_ as? D, q! s.
  21.     std::regex BoldText1("(([\\s\\w!?.,]*[*]{2}[\\s\\w!?.,]*[*]{2}[\\s\\w!?.,]*)+)"); //ab? c, qw **as? fa! q,s!**as? D, q! s.
  22.     std::regex BoldText2("(([\\s\\w!?.,]*[_]{2}([\\s\\w!?.,]*)[_]{2}([\\s\\w!?.,]*))+)"); //ab? c, qw __as? fa! q,s!__ as? D, q! s.
  23.     std::regex BoldIntalic1("(([\\s\\w!?.,]*[_]{3}([\\s\\w!?.,]*)[_]{3}([\\s\\w!?.,]*))+)");
  24.     std::regex BoldIntalic2("(([\\s\\w!?.,]*[*]{3}([\\s\\w!?.,]*)[*]{3}([\\s\\w!?.,]*))+)");
  25.  
  26.     //---------------------
  27.     string str = "";
  28.     //FILE* f;
  29.     //f = fopen("E:\\‪‪test.txt","w");
  30.     fstream code;
  31.     code.open("E:\\‪‪test.txt",ios::in|ios::out);
  32.     while (code)
  33.     {
  34.         line++;
  35.         correct = false;
  36.         getline(code, str);
  37.         if (std::regex_match(str.c_str(), RegularHadings))
  38.         {
  39.             correct = true;
  40.         }
  41.         if (std::regex_match(str.c_str(), ItalicText1))
  42.         {
  43.             correct = true;
  44.         }
  45.         if (std::regex_match(str.c_str(), ItalicText2))
  46.         {
  47.             correct = true;
  48.         }
  49.         if (std::regex_match(str.c_str(), BoldText1))
  50.         {
  51.             correct = true;
  52.         }
  53.         if (std::regex_match(str.c_str(), BoldText2))
  54.         {
  55.             correct = true;
  56.         }
  57.         if (std::regex_match(str.c_str(), BoldIntalic1))
  58.         {
  59.             correct = true;
  60.         }
  61.         if (std::regex_match(str.c_str(), BoldIntalic2))
  62.         {
  63.             correct = true;
  64.         }
  65.         if (std::regex_match(str.c_str(), RegularText))
  66.         {
  67.             correct = true;
  68.         }
  69.         if (correct == true)
  70.             allcorrect = true;
  71.         else
  72.         {
  73.             allcorrect = false;
  74.             printf("There is a mistake in line %d!\n", line);
  75.             break;
  76.         }
  77.  
  78.     }
  79.     if (allcorrect == true)
  80.         printf("All correct!\n");
  81.     printf("Everything is checked!\nPress any key to continue...");
  82.     getchar();
  83.  
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement