javascript中的正则表达式对象用的哪个COM?

解决方案 »

  1.   

    javascript如果用在ie中,则不需要特别支持,ms的script engine本身就支持了。查阅javascript文档。使用很简单。
      

  2.   

    不是用在ie中的
    load dll进来
      

  3.   

    // regexptest.cpp : Defines the entry point for the console application.
    //#include "stdafx.h"
    //ʹÓÃVC++ÒÔ×ÊÔ´µÄ·½Ê½´ò¿ªVBScript.dll£¬ÔÚÆäÖÐÑ¡ÔñTypeLib£¬½«µÚ2¸öTypeLibÊä³öΪregexp.tlb
    #import "regexp.tlb" no_namespaceint 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;
    }