Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Queequeg92 committed Nov 19, 2014
1 parent e343cad commit 0c0cd41
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ch17/ex17.14.15.16/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
using std::cout;
using std::cin;
Expand All @@ -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!" <<endl;

cout << "Please input a word! Input 'q' to quit!" << endl;
}

cout << endl;

//! for ex17.16
r.assign("[^c]ei", regex::icase);
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!" <<endl;

cout << "Please input a word! Input 'q' to quit!" << endl;
}

return 0;
Expand Down

0 comments on commit 0c0cd41

Please sign in to comment.