2.2 Using Soul Regular Expression Library

2.2.1 Creating a Project

To create a project that uses the Soul regular expression library:

2.2.2 Example

I have created an example program that uses the regular expression component:

// main.cpp:

import std.core;
import std.filesystem;
import util;
import soul.rex;

int main()
{
    try
    {
        util::Init();
        soul::rex::context::Context context;
        soul::rex::nfa::Nfa nfa = soul::rex::CompileFilePattern(context, "*.xml");
        for (const auto& entry : std::filesystem::directory_iterator{ "C:/soul-4.0.0/soul/xml/xml_test_data" })
        {
            if (entry.is_regular_file())
            {
                std::string fileName = entry.path().filename().generic_string();
                if (soul::rex::PatternMatch(fileName, nfa))
                {
                    std::cout << fileName << std::endl;
                }
            }

        }
    }
    catch (const std::exception& ex)
    {
        std::cerr << ex.what() << std::endl;
        return 1;
    }
    util::Done();
    return 0;
}

2.2.3 Adding References

To add references to the required modules to your project:

2.2.4 Adding Lexer Resource Files

To add required lexer resource files to your project:

2.2.5 Compiling the Solution