#include <regex.h>
#include <stdio.h>
#include <iostream>
using namespace std;
void Regex()
{
const char* text="#87655#23432#43354#456#";//开头,结尾
const char* pRegexStr ="^[#][0-9]//+[#][0-9]//+[#][0-9]//+[#][0-9]//+[#]{1}quot;;//有时候"+"号前要有两个"/"
regex_t oRegex;
int nErrCode = 0;
if ((nErrCode = regcomp(&oRegex, pRegexStr, 0)) == 0)
{
if ((nErrCode = regexec(&oRegex, text, 0, NULL, 0)) == 0)
{
printf("%s matches %s/n", text, pRegexStr);
}
else
{
cout<<"字符不匹配!!!"<<endl;
}
}
else
{
cout<<"正则表达式不正确,编译不成功!!!"<<endl;
}
regfree(&oRegex);
}
http://www.wuzesheng.com/?p=929 关键函数的解释
windows下c++ 正则表达式的使用:http://msdn.microsoft.com/zh-cn/library/4384yce9.aspx