现在的位置: 首页 > 综合 > 正文

VS2005(VC8)编译、配置Boost.regex

2013年03月19日 ⁄ 综合 ⁄ 共 466字 ⁄ 字号 评论关闭
 1,配置vs2005的控制台编译环境 (参考这里)
2,cd %Boost%/libs/regex/build
     cmd>nmake -fvc80.mak
3,添加%Boost%到vs2005的include目录;添加%Boost%/libs/regex/build/vc80到library目录
4,测试

// 正規表示法測試:信用卡號檢測
#include <boost/regex.hpp>
#include <iostream>

bool validate_card_format(const std::string s)
{
        static const boost::regex e("(//d{4}[- ]){3}//d{4}");
        return regex_match(s, e);
}

int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << (validate_card_format("1111-1111-1111-2222")?"PASS":"Error") ; // PASS

    return 0;
}

抱歉!评论已关闭.