How to Use regular expression in VC6?

Hi Community,

How can I use regular expression in VC6? I tried below sample code but it gives me an error as VC6 not supported atlcoll.h.

// 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;
}

regards,
titanium
titanium0203Asked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
You might want to try GRETA ("The GRETA Regular Expression Template Archive") for that purpose instead: http://research.microsoft.com/en-us/downloads/bd99f343-4ff4-4041-8293-34c054efe749/default.aspx
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
To the best of my knowledge that class (CAtlRegExp) is only available for more recent versions of visual studio.
Two options:
Get a newer version of visual studio
Find a third party utility or write one yourself  (There should be regex support in the boost libraries for example)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.