#include "stdafx.h"
//使用VC++以资源的方式打开VBScript.dll,在其中选择TypeLib,将第2个TypeLib输出为regexp.tlb, put it in your project's main directory
#import "regexp.tlb" no_namespace
int main(int argc, char* argv[])
{
CoInitialize(NULL);
{
IRegExpPtr regExpPtr(__uuidof(RegExp));
regExpPtr->PutGlobal(VARIANT_TRUE);
regExpPtr->PutPattern("(//d+//.?//d*|//.//d+)");
LPCTSTR testStr = "This 1dd2d";
IMatchCollectionPtr matches = regExpPtr->Execute(testStr);//用指针要出错
int count = matches->GetCount();//count=0 判断 matches 应该是正确的
for(int i=0; i<count; i++)
{
IMatchPtr match=matches->GetItem((long)i);
if(match)
{
printf("%s/n",(LPCTSTR)match->GetValue());
}
}
}
CoUninitialize();
printf("Test of using regular expression in VC++!/n");
return 0;
}
//使用VC++以资源的方式打开VBScript.dll,在其中选择TypeLib,将第2个TypeLib输出为regexp.tlb, put it in your project's main directory
#import "regexp.tlb" no_namespace
int main(int argc, char* argv[])
{
CoInitialize(NULL);
{
IRegExpPtr regExpPtr(__uuidof(RegExp));
regExpPtr->PutGlobal(VARIANT_TRUE);
regExpPtr->PutPattern("(//d+//.?//d*|//.//d+)");
LPCTSTR testStr = "This 1dd2d";
IMatchCollectionPtr matches = regExpPtr->Execute(testStr);//用指针要出错
int count = matches->GetCount();//count=0 判断 matches 应该是正确的
for(int i=0; i<count; i++)
{
IMatchPtr match=matches->GetItem((long)i);
if(match)
{
printf("%s/n",(LPCTSTR)match->GetValue());
}
}
}
CoUninitialize();
printf("Test of using regular expression in VC++!/n");
return 0;
}