看板 C_and_CPP 關於我們 聯絡資訊
想請問對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
tinlans:你沒看清楚那個說明的整段內容嗎? 04/26 17:38
tinlans:and all the previous captures will have been forgotten 04/26 17:38
tinlans:關於上面這段話附近的說明。 04/26 17:38