[問題] boost regex的match
想請問對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
04/26 17:38, 2F
→
04/26 17:38, , 3F
04/26 17:38, 3F