人気ブログランキング | 話題のタグを見る
VC++ 7.0 以降で正規表現
VC7で、正規表現を使いたいと思って調べてみたら、ATLでサポートされているんですね。
サンプルもMSDNに載っていて、簡単そうだし。
でも、正規表現の表現方法って、どうしてライブラリごとに違うんだろうか??
似通ってはいるけど、ライブラリごとに少しずつ違う。

とりあえず、テスト的なコードで動作を確認。

#include <atlrx.h>

...(中略)...

CAtlRegExp<> regex;

REParseError status = regex.Parse("^[0-9]+$");
if (REPARSE_ERROR_OK != status)
{
    AfxMessageBox("Parse Error!");
    return;
}

CAtlREMatchContext<> match;
if(regex.Match("0123", &match))
{
    AfxMessageBox("Match!");
}
else
{
    AfxMessageBox("Miss match!");
}
return;

ソニーストア

by isoq | 2008-11-19 22:13 | C/C++/Win32
<< おっふぃcえぃう゛ぇ | おっ... 点灯式 >>