{"id":20884601,"url":"https://github.com/adam-mcdaniel/regex-engine","last_synced_at":"2025-04-11T01:45:34.318Z","repository":{"id":232477248,"uuid":"784465985","full_name":"adam-mcdaniel/regex-engine","owner":"adam-mcdaniel","description":"A Regex📋 implementation in C++ using Thompson's NFA algorithm","archived":false,"fork":false,"pushed_at":"2024-04-19T21:37:25.000Z","size":4206,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T22:51:24.255Z","etag":null,"topics":["cpp","cpp98-compatible","header-only","regex","regex-engine","regex-match","text-processing"],"latest_commit_sha":null,"homepage":"https://adam-mcdaniel.net","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adam-mcdaniel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-09T22:54:42.000Z","updated_at":"2024-10-29T04:28:41.000Z","dependencies_parsed_at":"2024-04-10T01:22:35.374Z","dependency_job_id":"23bb8042-b589-4d1a-88aa-3cee1062b089","html_url":"https://github.com/adam-mcdaniel/regex-engine","commit_stats":null,"previous_names":["adam-mcdaniel/regex-engine"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fregex-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fregex-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fregex-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fregex-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adam-mcdaniel","download_url":"https://codeload.github.com/adam-mcdaniel/regex-engine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248327863,"owners_count":21085258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp98-compatible","header-only","regex","regex-engine","regex-match","text-processing"],"created_at":"2024-11-18T08:10:39.078Z","updated_at":"2025-04-11T01:45:34.298Z","avatar_url":"https://github.com/adam-mcdaniel.png","language":"C++","readme":"# regex-engine\n\n![Header Image](assets/header.png)\n\nThis repository implements a regex engine in C++ using Thompson's NFA algorithm. This algorithm prevents pathological backtracking, a common problem with most widely used regex implementations.\n\nThis implementation is also a header-only library.\n\n## Usage\n\nTo use the library, first include it in your C++ file.\n\n```c++\n// Optionally, you can define `CACHING` to allow\n// the regex engine to cache transition states.\n// This can improve performance in many cases.\n#define CACHING\n\n// Include the regex header file\n#include \"regex.hpp\"\n```\n\nTo use the regex engine, first create a regex object with the desired regex pattern. You can use `std::cout` to print out the compiled regex NFA. Use the `match` method to use the regex on a given content string.\n\n```c++\nint main() {\n    // Compile a regex pattern\n    Regex r(\"((ab)*|c)+\");\n\n    // Print out the compiled NFA\n    std::cout \u003c\u003c r \u003c\u003c std::endl;\n\n    // The content to match\n    std::string content = \"abc\";\n\n    // Check if the content matches the regex\n    if (r.match(content)) {\n        std::cout \u003c\u003c \"Matched!\" \u003c\u003c std::endl;\n    } else {\n        std::cout \u003c\u003c \"Not matched!\" \u003c\u003c std::endl;\n    }\n\n    return 0;\n}\n```\n\n## Regex Syntax\n\nThe regex engine supports the following syntax:\n\n| Syntax | Description |\n|--------|-------------|\n| `*` | Zero or more of the preceding expression |\n| `+` | One or more of the preceding expression |\n| `?` | Zero or one of the preceding expression |\n| `\\|` | Alternation |\n| `()` | Grouping |\n| `a`, `b`, `c`, ... | Any single character |\n\n\u003c!-- - `*` - Zero or more of the preceding expression\n- `+` - One or more of the preceding expression\n- `?` - Zero or one of the preceding expression\n- `|` - Alternation\n- `()` - Grouping\n- `a`, `b`, `c`, ... - Any character --\u003e\n\n## Building\n\nTo build your program with the regex engine, simply add it to your include path and link against the C++ standard library.\n\n```bash\ng++ -I path/to/regex-engine main.cpp -o main\n```\n\n### CMake\n\nTo build with CMake, you can use a `CMakeLists.txt` file like the following:\n\n```cmake\ncmake_minimum_required(VERSION 3.0)\n\n# Create a new project\nproject(HelloWorld)\n\n# Add an executable\nadd_executable(HelloWorld main.cpp)\n\ninclude_directories(path/to/regex-engine)\n```\n\nAlternatively, you can use `FetchContent` to download the regex engine repository and include it in your project.\n\n```cmake\n# Import the library from the git repo\ninclude(FetchContent)\n\nFetchContent_Declare(\n  regex-engine\n  GIT_REPOSITORY https://github.com/adam-mcdaniel/regex-engine\n  GIT_TAG        main\n)\n\nFetchContent_MakeAvailable(regex-engine)\n\n# Include the header only library\ninclude_directories(${regex-engine_SOURCE_DIR})\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-mcdaniel%2Fregex-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadam-mcdaniel%2Fregex-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-mcdaniel%2Fregex-engine/lists"}