1

with "basic" の意味: 演算子 "+" (->following..) および "|" のみ (->or) が必要です。

プロトタイプ:

preg_match_all(std::string pattern, std::string subject, std::vector<std::string> &matches)

使用例:

std::vector<std::string> matches;
std::string pattern, subject;
subject = "Some text with a lots of foo foo and " +  char(255) + " again " + char(255);
pattern = "/" + char(255) + char(255) + "+|foo+/";
preg_match_all(pattern, subject, matches);

マッチはその後、経由で利用できるはずですmatches[n]ブーストや PCREを使用せにヒントを得た人はいますか? そうでない場合、ブーストでこれを実現するにはどうすればよいですか?

4

3 に答える 3

0

std::string::findを使用して何かをロールアップし、ファンクターを介して一致を行い、結果を文字列ベクトルにプッシュできます。

ブーストで実現する方法は、おそらくあなたが望むものにはやり過ぎです-最初に式を語彙に分解し、次に指定された正規表現を解析するためにステートマシンをコンパイルする必要があります。

于 2010-02-01T15:30:27.163 に答える
0

Boost.Regex を調べてください。 http://www.boost.org/doc/libs/1_41_0/libs/regex/doc/html/index.html

于 2010-02-01T15:30:57.243 に答える