[問題] boost regex的match

看板C_and_CPP作者 (筆)時間15年前 (2009/04/26 00:46), 編輯推噓0(003)
留言3則, 1人參與, 最新討論串1/1
想請問對boost regex有研究的前輩 我在boost regex的手冊裡看到一個範例 if(boost::regex_match(text, what, e, boost::match_extra)) { unsigned i, j; std::cout << "** Match found **\n Sub-Expressions:\n"; for(i = 0; i < what.size(); ++i) cout << " $" << i << " = \"" << what[i] << "\"\n"; } 當text="aBBcccDDDDDeeeeeeee" RE=(([[:lower:]]+)|([[:upper:]]+))+" 得到what中的內容: $0 = "aBBcccDDDDDeeeeeeee" $1 = "eeeeeeee" $2 = "eeeeeeee" $3 = "DDDDD" 不懂的是為什麼what[1]是印出eeeeeeee what[1]存放的是符合第一個括號的東西吧?! 麻煩前輩指點一二,感激不盡!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.217.27

04/26 17:38, , 1F
你沒看清楚那個說明的整段內容嗎?
04/26 17:38, 1F

04/26 17:38, , 2F
and all the previous captures will have been forgotten
04/26 17:38, 2F

04/26 17:38, , 3F
關於上面這段話附近的說明。
04/26 17:38, 3F
文章代碼(AID): #19ypvUR0 (C_and_CPP)