Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <windows.h>
- #include <set>
- #include <iomanip>
- #include <regex>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- bool correct;
- bool allcorrect = false;
- int line = 0;
- //Regular Expressions [\\s\\w!?.,] - slovo bogy, help ! ? Me.
- std::regex RegularText("([\\s\\w!?.,]+)");
- std::regex RegularHadings("([#]{1,6} [\\s\\w!?.,]*)");
- std::regex ItalicText1("(([\\s\\w!?.,]*[*]([\\s\\w!?.,]*)[*]([\\s\\w!?.,]*))+)"); //ab? c, qw *as? fa! q,s!* as? D, q! s.
- std::regex ItalicText2("(([\\s\\w!?.,]*[_]([\\s\\w!?.,]*)[_]([\\s\\w!?.,]*))+)"); //ab? c, qw _as? fa! q,s!_ as? D, q! s.
- std::regex BoldText1("(([\\s\\w!?.,]*[*]{2}[\\s\\w!?.,]*[*]{2}[\\s\\w!?.,]*)+)"); //ab? c, qw **as? fa! q,s!**as? D, q! s.
- std::regex BoldText2("(([\\s\\w!?.,]*[_]{2}([\\s\\w!?.,]*)[_]{2}([\\s\\w!?.,]*))+)"); //ab? c, qw __as? fa! q,s!__ as? D, q! s.
- std::regex BoldIntalic1("(([\\s\\w!?.,]*[_]{3}([\\s\\w!?.,]*)[_]{3}([\\s\\w!?.,]*))+)");
- std::regex BoldIntalic2("(([\\s\\w!?.,]*[*]{3}([\\s\\w!?.,]*)[*]{3}([\\s\\w!?.,]*))+)");
- //---------------------
- string str = "";
- //FILE* f;
- //f = fopen("E:\\test.txt","w");
- fstream code;
- code.open("E:\\test.txt",ios::in|ios::out);
- while (code)
- {
- line++;
- correct = false;
- getline(code, str);
- if (std::regex_match(str.c_str(), RegularHadings))
- {
- correct = true;
- }
- if (std::regex_match(str.c_str(), ItalicText1))
- {
- correct = true;
- }
- if (std::regex_match(str.c_str(), ItalicText2))
- {
- correct = true;
- }
- if (std::regex_match(str.c_str(), BoldText1))
- {
- correct = true;
- }
- if (std::regex_match(str.c_str(), BoldText2))
- {
- correct = true;
- }
- if (std::regex_match(str.c_str(), BoldIntalic1))
- {
- correct = true;
- }
- if (std::regex_match(str.c_str(), BoldIntalic2))
- {
- correct = true;
- }
- if (std::regex_match(str.c_str(), RegularText))
- {
- correct = true;
- }
- if (correct == true)
- allcorrect = true;
- else
- {
- allcorrect = false;
- printf("There is a mistake in line %d!\n", line);
- break;
- }
- }
- if (allcorrect == true)
- printf("All correct!\n");
- printf("Everything is checked!\nPress any key to continue...");
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement