{"id":19167507,"url":"https://github.com/tkdeng/goregex","last_synced_at":"2026-06-15T02:34:38.740Z","repository":{"id":255446880,"uuid":"850154806","full_name":"tkdeng/goregex","owner":"tkdeng","description":"A High Performance PCRE Regex Package That Uses A Cache.","archived":false,"fork":false,"pushed_at":"2024-11-11T22:02:34.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T23:26:36.886Z","etag":null,"topics":[],"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}},"created_at":"2024-08-31T02:28:04.000Z","updated_at":"2024-12-28T19:14:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"2fd4ef85-d51a-4c3a-99d8-5c5a21d9ec33","html_url":"https://github.com/tkdeng/goregex","commit_stats":null,"previous_names":["tkdeng/goregex"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tkdeng/goregex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fgoregex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fgoregex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fgoregex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fgoregex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkdeng","download_url":"https://codeload.github.com/tkdeng/goregex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fgoregex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34345577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","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":[],"created_at":"2024-11-09T09:37:56.061Z","updated_at":"2026-06-15T02:34:38.723Z","avatar_url":"https://github.com/tkdeng.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Regex\n\nA High Performance PCRE Regex Package That Uses A Cache.\n\nSimplifies the the go-pcre regex package.\nAfter calling a regex, the compiled output gets cached to improve performance.\n\nThis package uses the [go-pcre](https://github.com/GRbit/go-pcre) package for better performance.\n\n## Installation\n\n```shell\ngo get github.com/tkdeng/goregex\n```\n\n## Dependencies\n\n### Debian/Ubuntu (Linux)\n\n```shell script\n  sudo apt install libpcre3-dev\n```\n\n### Fedora (Linux)\n\n```shell script\n  sudo dnf install pcre-devel\n```\n\n### Arch (Linux)\n\n```shell script\n  sudo yum install pcre-dev\n```\n\n## Usage\n\n```go\nimport (\n  \"github.com/tkdeng/goregex\"\n)\n\nfunc main(){\n  // pre compile a regex into the cache\n  // this method also returns the compiled pcre.Regexp struct\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  // compile RE2 instead of PCRE\n  reg := regex.CompRE2(`re`)\n  reg, err := regex.CompTryRE2(`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 PCRE module\n  regex.IsValidPCRE(`re`)\n  \n  // determine if a regex is valid, and can be compiled by the builtin RE2 module\n  regex.IsValidRE2(`re`)\n  \n  // run a replace function (most advanced feature)\n  regex.Comp(`(?flags)re(capture group)`).RepFunc(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\n  regex.Comp(`re (capture)`).RepStr(myByteArray, []byte(\"test $1\"))\n  \n  // run a simple light replace function\n  regex.Comp(`re`).RepStrLit(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)\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 pcre.Regexp\n  regex.PCRE\n  \n  // an alias of *regexp.Regexp\n  regex.RE2\n  \n  // direct access to compiled pcre.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', data(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'), data(2)...)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fgoregex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkdeng%2Fgoregex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fgoregex/lists"}