{"id":20737235,"url":"https://github.com/aspiesoft/go-regex-re2","last_synced_at":"2026-05-23T03:35:40.213Z","repository":{"id":191227365,"uuid":"684206806","full_name":"AspieSoft/go-regex-re2","owner":"AspieSoft","description":"A performance improvement to the builtin RE2 module.","archived":false,"fork":false,"pushed_at":"2023-10-15T20:18:48.000Z","size":39,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T12:21:09.949Z","etag":null,"topics":["go","golang","re2","regex","regex-engine","regexp"],"latest_commit_sha":null,"homepage":"","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/AspieSoft.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":"2023-08-28T17:06:48.000Z","updated_at":"2024-04-26T21:20:15.000Z","dependencies_parsed_at":"2025-01-18T01:22:52.432Z","dependency_job_id":"a149905d-2eff-451c-ab00-c2ce03e0412a","html_url":"https://github.com/AspieSoft/go-regex-re2","commit_stats":null,"previous_names":["aspiesoft/go-regex-re2"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/AspieSoft/go-regex-re2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AspieSoft%2Fgo-regex-re2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AspieSoft%2Fgo-regex-re2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AspieSoft%2Fgo-regex-re2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AspieSoft%2Fgo-regex-re2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AspieSoft","download_url":"https://codeload.github.com/AspieSoft/go-regex-re2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AspieSoft%2Fgo-regex-re2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33381989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T01:21:08.577Z","status":"online","status_checked_at":"2026-05-23T02:00:05.530Z","response_time":53,"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":["go","golang","re2","regex","regex-engine","regexp"],"created_at":"2024-11-17T06:14:00.387Z","updated_at":"2026-05-23T03:35:35.202Z","avatar_url":"https://github.com/AspieSoft.png","language":"Go","funding_links":["https://paypal.me/shaynejrtaylor?country.x=US\u0026locale.x=en_US"],"categories":[],"sub_categories":[],"readme":"# Go Regex RE2\n\n[![donation link](https://img.shields.io/badge/buy%20me%20a%20coffee-paypal-blue)](https://paypal.me/shaynejrtaylor?country.x=US\u0026locale.x=en_US)\n\nA performance improvement to the builtin RE2 module.\n\nThis method adds a cache, and some better functions, and uses RE2 for compatability.\n\nIf you need more speed, checkout my other PCRE based module [go-regex](https://github.com/AspieSoft/go-regex).\n\n## Installation\n\n```shell script\n  go get github.com/AspieSoft/go-regex-re2/v2\n```\n\n## Usage\n\n```go\n\nimport (\n  \"github.com/AspieSoft/go-regex-re2/v2\"\n\n  // or for verbose function names\n  \"github.com/AspieSoft/go-regex-re2/v2/verbose\"\n)\n\n// this example will use verbose mode to make function names more clear\n\n// pre compile a regex into the cache\n// this method also returns the compiled pcre.Regexp struct\nregex.Compile(`re`)\n\n// compile a regex and safely escape user input\nregex.Compile(`re %1`, `this will be escaped .*`); // output: this will be escaped \\.\\*\nregex.Compile(`re %1`, `hello \\n world`); // output: hello \\\\n world (note: the \\ was escaped, and the n is literal)\ntree/v4.0.0\n// use %n to reference a param\n// use %{n} for param indexes with more than 1 digit\nregex.Compile(`re %1 and %2 ... %{12}`, `param 1`, `param 2` ..., `param 12`);\n\n// manually escape a string\n// note: the compile methods params are automatically escaped\nregex.Escape(`(.*)? \\$ \\\\$ \\\\\\$ regex hack blocked`)\n\n// determine if a regex is valid, and can be compiled by this module\nregex.IsValid(`re`)\n\n// determine if a regex is valid, and can be compiled by the builtin RE2 module\nregex.IsValidRE2(`re`)\n\n// run a replace function (most advanced feature)\nregex.Compile(`(?flags)re(capture group)`).ReplaceFunc(myByteArray, func(data func(int) []byte) []byte {\n  data(0) // get the string\n  data(1) // get the first capture group\n\n  return []byte(\"\")\n\n  // if the last option is true, returning nil will stop the loop early\n  return nil\n}, true /* optional: if true, will not process a return output */)\n\n// run a replace function\nregex.Compile(`re (capture)`).ReplaceString(myByteArray, []byte(\"test $1\"))\n\n// run a simple light replace function\nregex.Compile(`re`).ReplaceStringLiteral(myByteArray, []byte(\"all capture groups ignored (ie: $1)\"))\n\n// return a bool if a regex matches a byte array\nregex.Compile(`re`).Match(myByteArray)\n\n// split a byte array in a similar way to JavaScript\nregex.Compile(`re|(keep this and split like in JavaScript)`).Split(myByteArray)\n\n// a regex string is modified before compiling, to add a few other features\n`use \\' in place of ` + \"`\" + ` to make things easier`\n`(?#This is a comment in regex)`\n\n// an alias of *regexp.Regexp\nregex.RE2\n\n// direct access to compiled *regexp.Regexp\nregex.Compile(\"re\").RE\n\n\n// another helpful function\n// this method makes it easier to return results to a regex function\nregex.JoinBytes(\"string\", []byte(\"byte array\"), 10, 'c', data(2))\n\n// the above method can be used in place of this one\nappend(append(append(append([]byte(\"string\"), []byte(\"byte array\")...), []byte(strconv.Itoa(10))...), 'c'), data(2)...)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspiesoft%2Fgo-regex-re2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faspiesoft%2Fgo-regex-re2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspiesoft%2Fgo-regex-re2/lists"}