나는 부스트 :: http://www.boost.org/doc/libs/1_39_0/doc/html/xpressive.html xpressive 좋습니다. 가능한 솔루션의
하나 :
string text = "abcd abce abcd";
static const sregex abcd = as_xpr("abcd"); // static - faster
sregex abce = sregex::compile("abce") // compiled
sregex all = *(keep(abcd) | keep(abce));
smatch what;
if(regex_match(text, what, all))
{
smatch::nested_results_type::const_iterator begin = what.nested_results().begin();
smatch::nested_results_type::const_iterator end = what.nested_results().end();
for(;it != end; it++)
{
if(it->regex_id() == abcd.regex_id())
{
// you match abcd
// use it->begin() and it->end()
// or it->position() and it->length()
continue;
}
if(it->regex_id() == abce.regex_id())
{
// you match abcd...
continue;
};
}
내 생각은하지 않는 것이 좋습니다 솔루션, 당신은 설명서의 "의미 작업 및 사용자 정의 어설"을 확인 할 수 있습니다.
간단하거나 "abcd"또는 "abce"와 그 위치 만 찾을 수 있습니다. 위와 같은 경우 abcd의 위치 만 찾습니다. – HellSpam
아니요, 또는 abcd | abce의 (변경)은 abcd 또는 abce가 일치하는 모든 위치를 찾아야합니다. – Avi