From 0c0cd419de59a54de78d1ac0989107424cfc18a6 Mon Sep 17 00:00:00 2001 From: Queequeg Date: Wed, 19 Nov 2014 13:03:30 +0800 Subject: [PATCH] fix bug --- ch17/ex17.14.15.16/main.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ch17/ex17.14.15.16/main.cpp b/ch17/ex17.14.15.16/main.cpp index 9f6bff75..ee3699fc 100644 --- a/ch17/ex17.14.15.16/main.cpp +++ b/ch17/ex17.14.15.16/main.cpp @@ -21,6 +21,8 @@ //! initialized with "[^c]ei"? Test your program using that pattern to see //! whether your expectations were correct. +//! Note: The program compiles with gcc version 4.9 or higher. + #include using std::cout; using std::cin; @@ -46,13 +48,32 @@ int main() } //! for ex17.15 - regex r("[[:alpha:]]*e[[:alpha:]]*i[[:alpha:]]*c[[:alpha:]]*", regex::icase); + regex r("[[:alpha:]]*[^c]ei[[:alpha:]]*", regex::icase); string s; cout << "Please input a word! Input 'q' to quit!" << endl; while(cin >> s && s != "q") { if(std::regex_match(s, r)) cout << "Input word " << s << " is okay!" << endl; + else + cout << "Input word " << s << " is not okay!" <> s && s != "q") + { + if(std::regex_match(s, r)) + cout << "Input word " << s << " is okay!" << endl; + else + cout << "Input word " << s << " is not okay!" <