Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <exception>
- #include <regex>
- #include <string>
- int main()
- {
- try {
- std::regex r("[[:alpha:]]*(cie|[^c]ei)[[:alpha:]]*");
- std::string word;
- while(std::cout << "Enter a word or 'q' to quit: ", std::cin >> word)
- {
- if(word == "q") break;
- std::smatch result;
- if(std::regex_search(word, result, r))
- {
- std::cout << "Violate the reule!" << std::endl;
- } else {
- std::cout << word << " is ok!" << std::endl;
- }
- }
- }
- catch (std::regex_error e)
- {
- std::cout << e.what() << std::endl << "Code: " << e.code() << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement