比如输入:work#则能找到 work1,work2,work3.......最后一位只能是数字.
是不是要一个一个的去和[1...9]的比较?

解决方案 »

  1.   

    你是要实现正则表达式还是用?用的话参考CAtlRegExp类。
      

  2.   

    请问楼上,在MFC中怎么用 CAtlRegExp类,有没有例子参考,谢谢了
      

  3.   


    // catlregexp_class.cpp
    #include <afx.h>
    #include <atlrx.h>int main(int argc, char* argv[])
    {
        CAtlRegExp<> reUrl;
        // Five match groups: scheme, authority, path, query, fragment
        REParseError status = reUrl.Parse(
            "({[^:/?#]+}:)?(//{[^/?#]*})?{[^?#]*}(?{[^#]*})?(#{.*})?" );    if (REPARSE_ERROR_OK != status)
        {
            // Unexpected error.
            return 0;
        }    CAtlREMatchContext<> mcUrl;
        if (!reUrl.Match(
    "http://search.microsoft.com/us/Search.asp?qu=atl&boolean=ALL#results",
            &mcUrl))
        {
            // Unexpected error.
            return 0;
        }    for (UINT nGroupIndex = 0; nGroupIndex < mcUrl.m_uNumGroups;
             ++nGroupIndex)
        {
            const CAtlREMatchContext<>::RECHAR* szStart = 0;
            const CAtlREMatchContext<>::RECHAR* szEnd = 0;
            mcUrl.GetMatch(nGroupIndex, &szStart, &szEnd);        ptrdiff_t nLength = szEnd - szStart;
            printf_s("%d: \"%.*s\"\n", nGroupIndex, nLength, szStart);
        }    return 0;
    }
      

  4.   

    报错:  fatal   error   C1083:   Cannot   open   include   file:   'atlrx.h':   No   such   file   or   directory  说明:我用的是VC6.0