{"id":15029698,"url":"https://github.com/google/re2j","last_synced_at":"2025-05-12T13:14:53.243Z","repository":{"id":27465985,"uuid":"30945132","full_name":"google/re2j","owner":"google","description":"linear time regular expression matching in Java","archived":false,"fork":false,"pushed_at":"2025-01-09T03:49:51.000Z","size":2512,"stargazers_count":1205,"open_issues_count":24,"forks_count":160,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-05-12T13:14:40.344Z","etag":null,"topics":["java","regular-expressions"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kohnfucius/network_proj","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2015-02-18T00:20:25.000Z","updated_at":"2025-04-22T04:02:55.000Z","dependencies_parsed_at":"2024-06-18T22:39:50.267Z","dependency_job_id":"93ce2cf6-6af4-440c-ac1a-e3962a8111d3","html_url":"https://github.com/google/re2j","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/re2j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"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":["java","regular-expressions"],"created_at":"2024-09-24T20:11:24.375Z","updated_at":"2025-05-12T13:14:53.213Z","avatar_url":"https://github.com/google.png","language":"Java","readme":"RE2/J: linear time regular expression matching in Java\n======================================================\n\n[![Build Status](https://github.com/google/re2j/actions/workflows/gradle.yaml/badge.svg?branch=master)](https://github.com/google/re2j/actions/workflows/gradle.yaml?query=branch%3Amaster)\n[![Coverage Status](https://codecov.io/gh/google/re2j/branch/master/graph/badge.svg?token=HL6dzvQ9kK)](https://codecov.io/gh/google/re2j)\n\nRE2 is a regular expression engine that runs in time linear in the size of the\ninput. RE2/J is a port of C++ library [RE2](https://github.com/google/re2) to pure Java.\n\nJava's standard regular expression package, `java.util.regex`, and many other\nwidely used regular expression packages such as PCRE, Perl and Python use a\nbacktracking implementation strategy: when a pattern presents two alternatives\nsuch as `a|b`, the engine will try to match subpattern `a` first, and if that\nyields no match, it will reset the input stream and try to match `b` instead.\n\nIf such choices are deeply nested, this strategy requires an exponential number\nof passes over the input data before it can detect whether the input matches.\nIf the input is large, it is easy to construct a pattern whose running time\nwould exceed the lifetime of the universe. This creates a security risk when\naccepting regular expression patterns from untrusted sources, such as users of\na web application.\n\nIn contrast, the RE2 algorithm explores all matches simultaneously in a single\npass over the input data by using a _nondeterministic_ finite automaton.\n\nThere are certain features of PCRE or Perl regular expressions that cannot be\nimplemented in linear time, for example, backreferences, but the vast majority\nof regular expressions patterns in practice avoid such features.\n\n# Why should I switch?\n\nIf you use regular expression patterns with a high degree of alternation, your\ncode may run faster with RE2/J. In the worst case, the `java.util.regex`\nmatcher may run forever, or exceed the available stack space and fail; this\nwill never happen with RE2/J.\n\n# Caveats\n\nThis is not an official Google product (experimental or otherwise), it is just\ncode that happens to be owned by Google.\n\nRE2/J is not a drop-in replacement for `java.util.regex`. Aside from the\ndifferent package name, it doesn't support the following parts of the\ninterface:\n\n* the MatchResult class\n* Matcher.hasAnchoringBounds()\n* Matcher.hasTransparentBounds()\n* Matcher.hitEnd()\n* Matcher.region(int, int)\n* Matcher.regionEnd()\n* Matcher.regionStart()\n* Matcher.requireEnd()\n* Matcher.toMatchResult()\n* Matcher.useAnchoringBounds(boolean)\n* Matcher.usePattern(Pattern)\n* Matcher.useTransparentBounds(boolean)\n* CANON_EQ\n* COMMENTS\n* LITERAL\n* UNICODE_CASE\n* UNICODE_CHARACTER_CLASS\n* UNIX_LINES\n* PatternSyntaxException.getMessage()\n\nIt also doesn't have parity with the full set of Java's character classes and\nspecial regular expression constructs.\n\n# Getting RE2/J\n\nIf you're using Maven, you can use the following snippet in your `pom.xml` to get RE2/J:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.google.re2j\u003c/groupId\u003e\n  \u003cartifactId\u003ere2j\u003c/artifactId\u003e\n  \u003cversion\u003e1.6\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nYou can use the same artifact details in any build system compatible with the Maven Central repositories (e.g. Gradle, Ivy).\n\nYou can also download RE2/J the old-fashioned way: go to [the RE2/J release tag](https://github.com/google/re2j/releases), download the RE2/J JAR and add it to your CLASSPATH.\n\n# Discussion and contribution\n\nWe have set up a Google Group for discussion, please join the [RE2/J discussion\nlist](http://groups.google.com/group/re2j-discuss) if you'd like to get in\ntouch.\n\nIf you would like to contribute patches, please see the [instructions for\ncontributors](CONTRIBUTING.md).\n\n# Who wrote this?\n\nRE2 was designed and implemented in C++ by Russ Cox. The C++ implementation\nincludes both NFA and DFA engines and numerous optimisations. Russ also ported\na simplified version of the NFA to Go. Alan Donovan ported the NFA-based Go\nimplementation to Java. Afroz Mohiuddin wrapped the engine in a familiar Java\n`Matcher` / `Pattern` API. James Ring prepared the open-source release\nand has been its primary maintainer since then.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fre2j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fre2j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fre2j/lists"}