龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC中使用SCRIPT 正则写的LRC歌词分析类(3)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
//-----test //CString t=delNotes((const char * )Text); //LrcMadeList(); //::MessageBox(::GetTopWindow(::GetDesktopWindow()),GetText(), "URL CLIENT", MB_OK); } // //删除注释 CString LRCOBJECT::delN

    //-----test
    //CString t=delNotes((const char * )Text);
    //LrcMadeList();
    //::MessageBox(::GetTopWindow(::GetDesktopWindow()),GetText(), "URL CLIENT", MB_OK);

}

// //删除注释
CString LRCOBJECT::delNotes(const char* str)
{
    CString m_reText;
    //CoInitialize(NULL);
    //-----------
    try
    {
        IRegExpPtr regExpPtr(__uuidof(RegExp));
        regExpPtr->PutGlobal(VARIANT_TRUE);
        regExpPtr->PutPattern("[d+:[d.]+](.*)[ ]");
        IMatchCollectionPtr matches = regExpPtr->Execute(str); //Execute方法接受的是_bstr_t类型,因此要进行(const char * )转换
        //-------
        IRegExpPtr IRegExpSubPtr(__uuidof(RegExp));
        IRegExpSubPtr->PutGlobal(VARIANT_TRUE);
        IRegExpSubPtr->PutPattern("[d+:[d.]+]");
        IMatchCollectionPtr matches2;
        //-----------------------
        int m_Count=matches->GetCount();
        int m_count2;
        CString m_SubText;
        if(m_Count>0)
        {
            for(int i=0;i<matches->GetCount();i++)
            {
                //IMatchPtr
                m_SubText=(LPCTSTR)((IMatchPtr)matches->GetItem(i))->GetValue();


                matches2=IRegExpSubPtr->Execute((const char *)m_SubText);
                if((m_count2=matches2->GetCount())>0)
                {
                    for(int j=0;j<m_count2;j++)
                    {
                        m_SubText.Replace((LPCTSTR)((IMatchPtr)matches2->GetItem(j))->GetValue(),"");
                    }

                    for(j=0;j<m_count2;j++)
                    {
                        m_reText+=(LPCTSTR)((IMatchPtr)matches2->GetItem(j))->GetValue()+m_SubText;
                    }
                }
                //::MessageBox(::GetTopWindow(::GetDesktopWindow()),m_reText, "URL CLIENT", MB_OK);
            }

精彩图集

赞助商链接