{"id":20558523,"url":"https://github.com/ravikisha/matchgo","last_synced_at":"2025-09-06T09:36:51.305Z","repository":{"id":260880531,"uuid":"882597659","full_name":"Ravikisha/matchgo","owner":"Ravikisha","description":"matchgo is a minimalistic regex engine that allows you to compile regex patterns, check strings for matches, and extract matched groups.","archived":false,"fork":false,"pushed_at":"2024-11-04T09:17:59.000Z","size":3354,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T07:31:54.251Z","etag":null,"topics":["golang","golang-library","regex","regex-engine"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/Ravikisha/matchgo","language":"Go","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/Ravikisha.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-11-03T09:27:16.000Z","updated_at":"2024-11-04T16:24:49.000Z","dependencies_parsed_at":"2024-11-03T10:20:18.229Z","dependency_job_id":"1c79eb99-ea92-4e50-96c4-a1461722372c","html_url":"https://github.com/Ravikisha/matchgo","commit_stats":null,"previous_names":["ravikisha/matchgo","ravikisha/gomatch"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Ravikisha/matchgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ravikisha%2Fmatchgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ravikisha%2Fmatchgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ravikisha%2Fmatchgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ravikisha%2Fmatchgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ravikisha","download_url":"https://codeload.github.com/Ravikisha/matchgo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ravikisha%2Fmatchgo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273886621,"owners_count":25185506,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["golang","golang-library","regex","regex-engine"],"created_at":"2024-11-16T03:44:26.535Z","updated_at":"2025-09-06T09:36:51.276Z","avatar_url":"https://github.com/Ravikisha.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Banner](./docs/banner.jpg)\n# matchgo\n\n\u003cp float=\"left\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/go-mod/go-version/Ravikisha/matchgo\" alt=\"Go version\" /\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/Ravikisha/matchgo\" alt=\"License\" /\u003e\n  \u003cimg alt=\"GoLang Logo\" src=\"https://img.shields.io/badge/Go-00ADD8?logo=go\u0026logoColor=white\" /\u003e\n\u003c/p\u003e\n\nA simple and experimental regex engine written in Go. This library is in development, so use it with caution!\n\n## Overview\n\n`matchgo` is a minimalistic regex engine that allows you to compile regex patterns, check strings for matches, and extract matched groups. While this implementation doesn't fully utilize all traditional regex construction techniques, it is inspired by the resources listed below.\n\n![Diagram](./docs/diagram.png)\n\n## Installation\n\nTo add `matchgo` as a dependency:\n\n```shell\ngo get github.com/Ravikisha/matchgo\n```\n\n## Usage\n\nHere’s how to use `matchgo`:\n\n```go\nimport \"github.com/Ravikisha/matchgo\"\n\npattern, err := matchgo.Compile(\"your-regex-pattern\")\nif err != nil {\n    // handle error\n}\n\nresult := pattern.Test(\"your-string\")\nif result.Matches {\n    // Access matched groups by name\n    groupMatchString := result.Groups[\"group-name\"]\n}\n```\n\nTo find all matches in a string, use `FindMatches`:\n\n```go\nmatches := pattern.FindMatches(\"your-string\")\nfor _, match := range matches {\n    // Process each match\n    if match.Matches {\n        fmt.Println(\"Match found:\", match.Groups)\n    }\n}\n```\n\n## Example\n\nHere’s an example of how to use `matchgo`:\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/Ravikisha/matchgo\"\n)\n\nfunc main() {\n  pattern, err := matchgo.Compile(\"([a-z]+) ([0-9]+)\")\n  if err != nil {\n    fmt.Println(\"Error compiling pattern:\", err)\n    return\n  }\n\n  result := pattern.Test(\"hello 123\")\n  if result.Matches {\n    fmt.Println(\"Match found:\", result.Groups)\n  }\n}\n```\n\nThis code will output:\n\n```\nMatch found: map[0:hello 123 1:hello 2:123]\n```\n\n## Features\n\n-  `^` beginning of the string\n-  `$` end of the string\n-  `.` any single character/wildcard\n-  bracket notation\n  -  `[ ]` bracket notation/ranges\n  -  `[^ ]` bracket negation notation\n  -  better handling of bracket expressions, e.g., `[ab-exy12]`\n  -  support for special characters in brackets\n    -  escape character support\n-  quantifiers\n  -  `*` none or more times\n  -  `+` one or more times\n  -  `?` optional\n  -  `{m,n}` between `m` and `n` times\n-  capturing groups\n  -  `( )` capturing groups\n  -  `\\n` backreference (e.g., `(dog)\\1`)\n  -  `\\k\u003cname\u003e` named backreference\n  -  string extraction for matches\n-  `\\` escape character\n  -  special character support (context-dependent)\n-  improved error handling\n-  multiline support (tested with *Alice in Wonderland* corpus)\n  -  `.` does not match newlines (`\\n`)\n  -  `$` matches newlines (`\\n`)\n  -  multiple full matches in one text\n\n## Notes\n\n- Escape sequences (`\\`) turn the next character into a literal without extended combinations like `\\d` or `\\b`.\n- Backreferences (`\\n`) are limited to single-digit references, so `\\10` would be interpreted as group `1` followed by a literal `0`.\n\n## Resources\n\nThese resources were consulted while developing `matchgo`:\n\n- [Implementing a Regex Engine](https://deniskyashif.com/2019/02/17/implementing-a-regular-expression-engine/)\n- [Regular expression - Wikipedia](https://en.wikipedia.org/wiki/Regular_expression)\n- [Shunting-yard algorithm - Wikipedia](https://en.wikipedia.org/wiki/Shunting_yard_algorithm)\n- [Converting Regular Expressions to Postfix Notation](https://blog.cernera.me/converting-regular-expressions-to-postfix-notation-with-the-shunting-yard-algorithm/)\n- [Go by Example](https://gobyexample.com/)\n- [Regex101](https://regex101.com/)\n- [Thompson’s Construction - Wikipedia](https://en.wikipedia.org/wiki/Thompson%27s_construction)\n- [Python re Tests](https://github.com/python/cpython/blob/main/Lib/test/re_tests.py)\n- [Microsoft .NET Regex Documentation](https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions)\n\n\u003e This project was inspired by [rgx](https://rhaeguard.github.io/posts/regex/).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravikisha%2Fmatchgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fravikisha%2Fmatchgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravikisha%2Fmatchgo/lists"}