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(
        // Unexpected error.
        return 0;

    for (UINT nGroupIndex = 0; nGroupIndex < mcUrl.m_uNumGroups;
        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;

Who is Participating?
jkrConnect With a Mentor Commented:
You might want to try GRETA ("The GRETA Regular Expression Template Archive") for that purpose instead:
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)
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.