{"id":28761064,"url":"https://github.com/tkdeng/regex","last_synced_at":"2026-04-15T06:11:18.786Z","repository":{"id":299396914,"uuid":"1002522970","full_name":"tkdeng/regex","owner":"tkdeng","description":"A High Performance Regex Package That Uses A Cache.","archived":false,"fork":false,"pushed_at":"2026-03-21T01:36:27.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-21T17:00:49.022Z","etag":null,"topics":["go","golang","re2","regex","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/tkdeng.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,"zenodo":null}},"created_at":"2025-06-15T16:46:52.000Z","updated_at":"2026-03-21T01:35:57.000Z","dependencies_parsed_at":"2025-06-16T11:12:02.776Z","dependency_job_id":"660b3329-09e9-4cae-885d-2abe52167c5e","html_url":"https://github.com/tkdeng/regex","commit_stats":null,"previous_names":["tkdeng/regex"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tkdeng/regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fregex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fregex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fregex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fregex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkdeng","download_url":"https://codeload.github.com/tkdeng/regex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fregex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31828569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"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","regexp"],"created_at":"2025-06-17T06:39:40.701Z","updated_at":"2026-04-15T06:11:18.771Z","avatar_url":"https://github.com/tkdeng.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Regex\n\nA High Performance Regex Package That Uses A Cache.\n\nAfter calling a regex, the compiled output gets cached to improve performance.\n\nThis package uses the core go regexp package under the hood, so its free from external dependencies.\n\n## Installation\n\n```shell\ngo get github.com/tkdeng/regex\n```\n\n## Usage\n\n```go\nimport (\n  \"github.com/tkdeng/regex\"\n)\n\nfunc main(){\n  // pre compile a regex into the cache\n  regex.Comp(`re`)\n\n  // compile a regex and safely escape user input\n  regex.Comp(`re %1`, `this will be escaped .*`); // output: this will be escaped \\.\\*\n  regex.Comp(`re %1`, `hello \\n world`); // output: hello \\\\n world (note: the \\ was escaped, and the n is literal)\n\n  // use %n to reference a param\n  // use %{n} for param indexes with more than 1 digit\n  regex.Comp(`re %1 and %2 ... %{12}`, `param 1`, `param 2` ..., `param 12`);\n\n  // return an error instead of panic on failed compile\n  reg, err := regex.CompTry(`re`)\n\n\n  // manually escape a string\n  // note: the compile methods params are automatically escaped\n  regex.Escape(`(.*)? \\$ \\\\$ \\\\\\$ regex hack failed`)\n\n  // determine if a regex is valid, and can be compiled by this module\n  regex.IsValid(`re`)\n\n  // determine if a regex is valid, and can be compiled by the builtin RE2 Regexp module\n  regex.IsValidRE2(`re`)\n\n  // run a replace function (most advanced feature)\n  regex.Comp(`(?flags)re(capture group)`).RepFunc(myByteArray, func(b func(int) []byte) []byte {\n    b(0) // get the string\n    b(1) // get the first capture group\n\n    return []byte(\"\")\n\n    // returning nil will stop the loop early\n    return nil\n  })\n\n  // replace with a string\n  regex.Comp(`re (capture)`).Rep(myByteArray, []byte(\"test $1\"))\n\n  // replace with a string literal\n  regex.Comp(`re`).RepLit(myByteArray, []byte(\"all capture groups ignored (ie: $1)\"))\n\n\n  // return a bool if a regex matches a byte array\n  regex.Comp(`re`).Match(myByteArray)\n\n  // split a byte array in a similar way to JavaScript\n  regex.Comp(`re|(keep this and split like in JavaScript)`).Split(myByteArray) // [][]byte\n  regex.Comp(`re|(keep this and split)`).SplitStr(myByteArray) // []string\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  // direct access to compiled *regexp.Regexp\n  regex.Comp(\"re\").RE\n\n\n  // another helpful function\n  // this method makes it easier to return results to a regex function\n  regex.JoinBytes(\"string\", []byte(\"byte array\"), 10, 'c', b(2))\n\n  // the above method can be used in place of this one\n  append(append(append(append([]byte(\"string\"), []byte(\"byte array\")...), []byte(strconv.Itoa(10))...), 'c'), b(2)...)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fregex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkdeng%2Fregex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fregex/lists"}