C++ regular expression, study notes
The first note:
The second note
/*regular experssion grammars:
ECMAScript powerful,
basic
extended
awk
grep
egrep
*/
#include
#include
using namespace std;
int main(){//
string t;
while(1){
cin>>t;
try {// http://www.cplusplus.com/reference/regex/ECMAScript
// regex e("ab"); // ab
// regex e("ab.",regex_constants::icase);//. , ,icase
// regex e("abc?"); //? ,
// regex e("abc*");//* ,
// regex e("abc+");//+ ,
// regex e("abc[def]");//[] , ,
// regex e("abc[def]*");// “ abc, [] abc 0,
// regex e("abc[^def]*");// , []
// regex e("abc[abc]{5}");//{} 。 abc 5 []
// regex e("abc|yuan[fang]");// | 。 abc, yuan[fang],
// regex e("abc|yuan[fang\]]");//\]
// regex e("(abc)de+(yuan)\\1\\2");//() , \\1,\\2 。 :abcdee...eeyuanabcyuan
//regex e("[[:w:]]+@[[:w:]]+.com");// , [[:w:]] word character:digital,number,or underscore
//http://www.cplusplus.com/reference/regex/ECMAScript
//bool match = regex_match(t,e);//
//regex e("ab.",regex_constants::icase);//. , ,icase
//regex e("^ab.",regex_constants::icase);//^ ,ab
regex e("ab.$",regex_constants::icase);//$ ,ab
bool match = regex_search(t, e); //
cout<
The second note
#include
#include
using namespace std;
int main(){//
string t;
while(1){
cin>>t;
smatch m; //typedef std::match_results
try {
regex e("([[:w:]]+)@([[:w:]]+).com");// ()
bool match = regex_search(t, m, e); // , smatch
cout<