{"id":21259584,"url":"https://github.com/howl-anderson/microregex","last_synced_at":"2025-07-11T03:30:42.839Z","repository":{"id":57441533,"uuid":"75079341","full_name":"howl-anderson/MicroRegEx","owner":"howl-anderson","description":"一个微型的正则表达式引擎 | A micro regular expression engine ","archived":false,"fork":false,"pushed_at":"2019-09-22T14:53:56.000Z","size":1737,"stargazers_count":36,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-07T04:47:49.724Z","etag":null,"topics":["finite-state-machine","regular-expression","regular-expression-engine"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/howl-anderson.png","metadata":{"files":{"readme":"README.en-US.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-29T12:28:01.000Z","updated_at":"2025-01-19T12:49:51.000Z","dependencies_parsed_at":"2022-09-06T02:40:40.979Z","dependency_job_id":null,"html_url":"https://github.com/howl-anderson/MicroRegEx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/howl-anderson/MicroRegEx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howl-anderson%2FMicroRegEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howl-anderson%2FMicroRegEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howl-anderson%2FMicroRegEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howl-anderson%2FMicroRegEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/howl-anderson","download_url":"https://codeload.github.com/howl-anderson/MicroRegEx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howl-anderson%2FMicroRegEx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264721279,"owners_count":23653910,"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":["finite-state-machine","regular-expression","regular-expression-engine"],"created_at":"2024-11-21T04:14:27.102Z","updated_at":"2025-07-11T03:30:42.408Z","avatar_url":"https://github.com/howl-anderson.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[中文版本的 README](README.md)\n------------------------------\n\n## What's MicroRegEx\nMicroRegEx is a micro regular expression engine.\n\n## Operator\n* `*` - zero or more repetitions\n* `+` - one or more repetitions\n* `?` - optional\n* `a|b` - matches a or b\n* `(expr)` - treat the `expr` as an atom\n* `\\` - escape character\n\n## Usage\n### Use like python built-in regex\n```python\nimport MicroRegEx\n\nregex = MicroRegEx.compile(\"(a|b)cd*e?\")\nresult = regex.match(\"abcde\")\nprint(result)\n\nresult = regex.match(\"acde\")\nprint(result)\n```\n\nwill output:\n```text\nFalse\nTrue\n```\n\n### Plot NFA\n```python\nimport MicroRegEx\n\nregex = MicroRegEx.compile(\"(a|b)c?\")\nregex.plot()\n```\n\nwill plot graph as fellow:\n![NFA](img/nfa.png)\n\n### Translate to DFA\n#### NFA to DFA\n##### Native DFA\n```python\nimport MicroRegEx\nfrom MicroRegEx.Automaton.NFA2DFA import NFA2DFA\n\nnfa = MicroRegEx.compile(\"(a|b)c?\")\n\ndfa = NFA2DFA(nfa).convert()\ndfa.plot()\n```\n\nwill plot graph as fellow:\n![DFA_native](img/dfa_native.png)\n\n##### Simplified DFA\n```python\nimport MicroRegEx\nfrom MicroRegEx.Automaton.NFA2DFA import NFA2DFA\n\nnfa = MicroRegEx.compile(\"(a|b)c?\")\n\ndfa = NFA2DFA(nfa).convert().simplify()\ndfa.plot()\n```\n\nwill plot graph as fellow:\n![DFA_simplified](img/dfa_simplified.png)\n\n#### DFA minimization\n##### Brzozowski method\n```python\nimport MicroRegEx\nfrom MicroRegEx.Automaton.NFA2DFA import NFA2DFA\nfrom MicroRegEx.Automaton.Minimal.Brzozowski import Brzozowski\n\nnfa = MicroRegEx.compile(\"(a|b)c?\")\n\ndfa = NFA2DFA(nfa).convert().simplify()\nmini_dfa = Brzozowski(dfa).construct()\nmini_dfa.plot()\n```\n\nwill plot graph as fellow:\n![DFA_mini](img/dfa_mini.png)\n\n## Understand MicroRegEx\nTo better understand how MicroRegEx works, I have provided a [Jupyter Notebook](example/explain_code.ipynb) that allows the user to gradually explore the underlying principles of MicroRegEx.\n\n## Test\nTest pass by a test data set which contains 64 examples. Please run `python ./testing.py` for a detailed test.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledge \u0026 Credits\n1. Inspire by the [regex](https://github.com/xysun/regex) project of [xysun](https://github.com/xysun)\n2. Some Documents from [regular\\_expression\\_engine](https://github.com/lihao98722/regular_expression_engine) project of [lihao98722](https://github.com/lihao98722/)\n3. Test suite is based on [Glenn Fowler](http://www.research.att.com/~gsf/testregex/)'s regex test suites.\n4. Test script is cloned from [regex](https://github.com/xysun/regex) project with some modification.\n\n## Reference\n* [Implementing Regular Expressions](https://swtch.com/~rsc/regexp/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowl-anderson%2Fmicroregex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhowl-anderson%2Fmicroregex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowl-anderson%2Fmicroregex/lists"}