{"id":13417848,"url":"https://github.com/google/re2","last_synced_at":"2025-09-09T21:03:24.783Z","repository":{"id":19825874,"uuid":"23086893","full_name":"google/re2","owner":"google","description":"RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.","archived":false,"fork":false,"pushed_at":"2025-08-13T13:26:49.000Z","size":10444,"stargazers_count":9415,"open_issues_count":4,"forks_count":1174,"subscribers_count":238,"default_branch":"main","last_synced_at":"2025-09-04T09:09:23.224Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-08-18T21:21:26.000Z","updated_at":"2025-09-04T06:16:05.000Z","dependencies_parsed_at":"2023-02-16T11:16:15.351Z","dependency_job_id":"fc8bef31-9654-44b6-994b-d43145e07f94","html_url":"https://github.com/google/re2","commit_stats":{"total_commits":1116,"total_committers":66,"mean_commits":16.90909090909091,"dds":"0.18727598566308246","last_synced_commit":"6dcd83d60f7944926bfd308cc13979fc53dd69ca"},"previous_names":[],"tags_count":87,"template":false,"template_full_name":null,"purl":"pkg:github/google/re2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/re2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fre2/sbom","scorecard":{"id":437777,"data":{"date":"2025-08-11","repo":{"name":"github.com/google/re2","commit":"6569a9a3df256f4c0c3813cb8ee2f8eef6e2c1fb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":7.5,"checks":[{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":9,"reason":"Found 29/30 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":9,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/pages.yml:33","Info: jobLevel 'contents' permission set to 'read': .github/workflows/pr.yml:11","Info: jobLevel 'contents' permission set to 'read': .github/workflows/python.yml:213","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release-bazel.yml:36","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release.yml:12","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release.yml:46","Info: topLevel 'contents' permission set to 'read': .github/workflows/ci-bazel.yml:6","Info: topLevel 'contents' permission set to 'read': .github/workflows/ci-cmake.yml:6","Info: topLevel 'contents' permission set to 'read': .github/workflows/ci.yml:6","Info: topLevel 'contents' permission set to 'read': .github/workflows/pages.yml:5","Info: topLevel 'contents' permission set to 'read': .github/workflows/pr.yml:7","Info: topLevel 'contents' permission set to 'read': .github/workflows/python.yml:13","Warn: no topLevel permission defined: .github/workflows/release-bazel.yml:1","Info: topLevel 'contents' permission set to 'read': .github/workflows/release.yml:6"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: OSSFuzz integration found","Info: CppLibFuzzer integration found: re2/fuzzing/re2_fuzzer.cc:241","Info: CppLibFuzzer integration found: re2/fuzzing/re2_fuzzer.cc:241"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci-bazel.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci-bazel.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci-bazel.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci-bazel.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci-bazel.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci-bazel.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci-cmake.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci-cmake.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci-cmake.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci-cmake.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci-cmake.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci-cmake.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/pages.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pages.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/pages.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/pages.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/pages.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/pages.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/pr.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/pr.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python.yml:103: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:106: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:135: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:161: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python.yml:165: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:173: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:202: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:218: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:222: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python.yml:238: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python.yml:254: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/python.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release-bazel.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/release-bazel.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/google/re2/release.yml/main?enable=pin","Warn: npmCommand not pinned by hash: app/build.sh:19","Warn: pipCommand not pinned by hash: .github/workflows/ci-bazel.yml:27","Warn: pipCommand not pinned by hash: .github/workflows/ci-bazel.yml:28","Warn: downloadThenRun not pinned by hash: .github/workflows/ci.yml:50","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:111","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:112","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:113","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:179","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:180","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:181","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:227","Warn: pipCommand not pinned by hash: .github/workflows/python.yml:228","Info:   0 out of  26 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   8 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned","Info:   2 out of  12 pipCommand dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/python.yml:207"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":8,"reason":"5 out of the last 5 releases have a total of 5 signed artifacts.","details":["Info: signed release artifact: re2-2025-08-12.tar.gz.sigstore.json: https://github.com/google/re2/releases/tag/2025-08-12","Info: signed release artifact: re2-2025-08-05.tar.gz.sigstore.json: https://github.com/google/re2/releases/tag/2025-08-05","Info: signed release artifact: re2-2025-07-22.tar.gz.sigstore.json: https://github.com/google/re2/releases/tag/2025-07-22","Info: signed release artifact: re2-2025-07-17.tar.gz.sigstore.json: https://github.com/google/re2/releases/tag/2025-07-17","Info: signed release artifact: re2-2024-07-02.tar.gz.sigstore: https://github.com/google/re2/releases/tag/2024-07-02","Warn: release artifact 2025-08-12 does not have provenance: https://api.github.com/repos/google/re2/releases/239503033","Warn: release artifact 2025-08-05 does not have provenance: https://api.github.com/repos/google/re2/releases/237766110","Warn: release artifact 2025-07-22 does not have provenance: https://api.github.com/repos/google/re2/releases/234288444","Warn: release artifact 2025-07-17 does not have provenance: https://api.github.com/repos/google/re2/releases/233330147","Warn: release artifact 2024-07-02 does not have provenance: https://api.github.com/repos/google/re2/releases/163359306"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}}]},"last_synced_at":"2025-08-19T05:04:26.073Z","repository_id":19825874,"created_at":"2025-08-19T05:04:26.073Z","updated_at":"2025-08-19T05:04:26.073Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273679960,"owners_count":25148701,"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-04T02:00:08.968Z","response_time":61,"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-07-30T22:00:53.924Z","updated_at":"2025-09-09T21:03:24.769Z","avatar_url":"https://github.com/google.png","language":"C++","readme":"# RE2, a regular expression library\n\nRE2 is an efficient, principled regular expression library\nthat has been used in production at Google and many other places\nsince 2006.\n\n_**Safety is RE2's primary goal.**_\n\nRE2 was designed and implemented with an explicit goal of being able\nto handle regular expressions from untrusted users without risk.\nOne of its primary guarantees is that the match time is linear in the\nlength of the input string. It was also written with production concerns in mind:\nthe parser, the compiler and the execution engines limit their memory usage\nby working within a configurable budget—failing gracefully when exhausted—and\nthey avoid stack overflow by eschewing recursion.\n\nIt is not a goal to be faster than all other engines under all circumstances.\nAlthough RE2 guarantees a running time that is asymptotically linear in\nthe length of the input, more complex expressions may incur larger constant factors;\nlonger expressions increase the overhead required to handle those expressions safely.\nIn a sense, RE2 is pessimistic where a backtracking engine is optimistic:\nA backtracking engine tests each alternative sequentially, making it fast when the first alternative is common.\nBy contrast RE2 evaluates all alternatives in parallel, avoiding the performance penalty for the last alternative,\nat the cost of some overhead. This pessimism is what makes RE2 secure.\n\nIt is also not a goal to implement all of the features offered by Perl, PCRE and other engines.\nAs a matter of principle, RE2 does not support constructs for which only backtracking solutions are known to exist.\nThus, backreferences and look-around assertions are not supported.\n\nFor more information, please refer to Russ Cox's articles on regular expression theory and practice:\n\n* [Regular Expression Matching Can Be Simple And Fast](https://swtch.com/~rsc/regexp/regexp1.html)\n* [Regular Expression Matching: the Virtual Machine Approach](https://swtch.com/~rsc/regexp/regexp2.html)\n* [Regular Expression Matching in the Wild](https://swtch.com/~rsc/regexp/regexp3.html)\n\n### Syntax\n\nIn POSIX mode, RE2 accepts standard POSIX (egrep) syntax regular expressions.\nIn Perl mode, RE2 accepts most Perl operators.  The only excluded ones are\nthose that require backtracking (and its potential for exponential runtime)\nto implement.  These include backreferences (submatching is still okay)\nand generalized assertions.\nThe [Syntax wiki page](https://github.com/google/re2/wiki/Syntax)\ndocuments the supported Perl-mode syntax in detail.\nThe default is Perl mode.\n\n### C++ API\n\nRE2's native language is C++, although there are [ports and wrappers](#ports-and-wrappers) listed below.\n\n#### Matching Interface\n\nThere are two basic operators:\n`RE2::FullMatch` requires the regexp to match the entire input text, and\n`RE2::PartialMatch` looks for a match for a substring of the input text,\nreturning the leftmost-longest match in POSIX mode and the\nsame match that Perl would have chosen in Perl mode.\n\nExamples:\n\n```cpp\nassert(RE2::FullMatch(\"hello\", \"h.*o\"))\nassert(!RE2::FullMatch(\"hello\", \"e\"))\n\nassert(RE2::PartialMatch(\"hello\", \"h.*o\"))\nassert(RE2::PartialMatch(\"hello\", \"e\"))\n```\n\n#### Submatch Extraction\n\nBoth matching functions take additional arguments in which submatches will be stored.\nThe argument can be a `string*`, or an integer type, or the type `absl::string_view*`.\n(The `absl::string_view` type is very similar to the `std::string_view` type,\nbut for historical reasons, RE2 uses the former.)\nA `string_view` is a pointer to the original input text, along with a count.\nIt behaves like a string but doesn't carry its own storage.\nLike when using a pointer, when using a `string_view`\nyou must be careful not to use it once the original text has been deleted or gone out of scope.\n\nExamples:\n\n```cpp\n// Successful parsing.\nint i;\nstring s;\nassert(RE2::FullMatch(\"ruby:1234\", \"(\\\\w+):(\\\\d+)\", \u0026s, \u0026i));\nassert(s == \"ruby\");\nassert(i == 1234);\n\n// Fails: \"ruby\" cannot be parsed as an integer.\nassert(!RE2::FullMatch(\"ruby\", \"(.+)\", \u0026i));\n\n// Success; does not extract the number.\nassert(RE2::FullMatch(\"ruby:1234\", \"(\\\\w+):(\\\\d+)\", \u0026s));\n\n// Success; skips NULL argument.\nassert(RE2::FullMatch(\"ruby:1234\", \"(\\\\w+):(\\\\d+)\", (void*)NULL, \u0026i));\n\n// Fails: integer overflow keeps value from being stored in i.\nassert(!RE2::FullMatch(\"ruby:123456789123\", \"(\\\\w+):(\\\\d+)\", \u0026s, \u0026i));\n```\n\n#### Pre-Compiled Regular Expressions\n\nThe examples above all recompile the regular expression on each call.\nInstead, you can compile it once to an RE2 object and reuse that object for each call.\n\nExample:\n```cpp\nRE2 re(\"(\\\\w+):(\\\\d+)\");\nassert(re.ok());  // compiled; if not, see re.error();\n\nassert(RE2::FullMatch(\"ruby:1234\", re, \u0026s, \u0026i));\nassert(RE2::FullMatch(\"ruby:1234\", re, \u0026s));\nassert(RE2::FullMatch(\"ruby:1234\", re, (void*)NULL, \u0026i));\nassert(!RE2::FullMatch(\"ruby:123456789123\", re, \u0026s, \u0026i));\n```\n\n#### Options\n\nThe constructor takes an optional second argument that can\nbe used to change RE2's default options.\nFor example, `RE2::Quiet` silences the error messages that are\nusually printed when a regular expression fails to parse:\n\n```cpp\nRE2 re(\"(ab\", RE2::Quiet);  // don't write to stderr for parser failure\nassert(!re.ok());  // can check re.error() for details\n```\n\nOther useful predefined options are `Latin1` (disable UTF-8) and `POSIX`\n(use POSIX syntax and leftmost longest matching).\n\nYou can also declare your own `RE2::Options` object and then configure it as you like.\nSee the [header](https://github.com/google/re2/blob/main/re2/re2.h) for the full set of options.\n\n#### Unicode Normalization\n\nRE2 operates on Unicode code points: it makes no attempt at normalization.\nFor example, the regular expression /ü/ (U+00FC, u with diaeresis)\ndoes not match the input \"ü\" (U+0075 U+0308, u followed by combining diaeresis).\nNormalization is a long, involved topic.\nThe simplest solution, if you need such matches, is to normalize both the regular expressions\nand the input in a preprocessing step before using RE2.\nFor more details on the general topic, see \u003chttps://www.unicode.org/reports/tr15/\u003e.\n\n#### Additional Tips and Tricks\n\nFor advanced usage, like constructing your own argument lists,\nor using RE2 as a lexer, or parsing hex, octal, and C-radix numbers,\nsee [re2.h](https://github.com/google/re2/blob/main/re2/re2.h).\n\n### Installation\n\nRE2 can be built and installed using GNU make, CMake, or Bazel.\nThe simplest installation instructions are:\n\n\tmake\n\tmake test\n\tmake benchmark\n\tmake install\n\tmake testinstall\n\nBuilding RE2 requires a C++17 compiler and the [Abseil](https://github.com/abseil/abseil-cpp) library.\nBuilding the tests and benchmarks requires\n[GoogleTest](https://github.com/google/googletest)\nand [Benchmark](https://github.com/google/benchmark).\nTo obtain those:\n\n- Linux: `apt install libabsl-dev libgtest-dev libbenchmark-dev`\n- macOS: `brew install abseil googletest google-benchmark pkg-config-wrapper`\n- Windows: `vcpkg install abseil gtest benchmark` \\\n  or `vcpkg add port abseil gtest benchmark`\n\nOnce those are installed, the build has to be able to find them.\nIf the standard Makefile has trouble, then switching to CMake can help:\n\n\trm -rf build\n\tcmake -DRE2_TEST=ON -DRE2_BENCHMARK=ON -S . -B build\n\tcd build\n\tmake\n\tmake test\n\tmake install\n\nWhen using CMake, with benchmarks enabled, `make test` builds and runs test binaries\nand builds a `regexp_benchmark` binary but does not run it.\nIf you don't need the tests or benchmarks at all, you can omit the corresponding `-D` arguments,\nand then you don't need the GoogleTest or Benchmark dependencies either.\n\nAnother useful option is `-DRE2_USE_ICU=ON`, which adds a dependency on the\nICU Unicode library but also extends the list of property names available in the `\\p` and `\\P` patterns.\n\nCMake can also be used to generate Visual Studio and Xcode projects, as well as\nCygwin, MinGW, and MSYS makefiles.\n\n - Visual Studio users: You need Visual Studio 2019 or later.\n - Cygwin users: You must run CMake from the Cygwin command line, not the Windows command line.\n\nIf you are adding RE2 to your own CMake project,\nCMake has two ways to use a dependency: `add_subdirectory()`,\nwhich is when the dependency's **_sources_** are in a subdirectory of your project;\nand `find_package()`, which is when the dependency's\n**_binaries_** have been built and installed somewhere on your system.\nThe Abseil documentation walks through the former [here](https://abseil.io/docs/cpp/quickstart-cmake)\nversus the latter [here](https://abseil.io/docs/cpp/tools/cmake-installs).\nOnce you get Abseil working, getting RE2 working will be a very similar process and,\neither way, `target_link_libraries(… re2::re2)` should Just Work™.\n\nIf you are using [Bazel](https://bazel.io), it will handle the dependencies for you,\nalthough you still need to download Bazel,\nwhich you can do with [Bazelisk](https://github.com/bazelbuild/bazelisk).\n\n\tgo install github.com/bazelbuild/bazelisk@latest\n\t# or on mac: brew install bazelisk\n\n\tbazelisk build :all\n\tbazelisk test :all\n\nIf you are using RE2 from another project, you need to make sure you are\nusing at least C++17.\nSee the RE2 [.bazelrc](https://github.com/google/re2/blob/main/.bazelrc) file for an example.\n\n### Ports and Wrappers\n\nRE2 is implemented in C++.\n\nThe official Python wrapper is [in the `python` directory](https://github.com/google/re2/tree/main/python)\nand [published on PyPI as `google-re2`](https://pypi.org/project/google-re2/).\nNote that there is also a PyPI `re2` but it is not by the RE2 authors and is unmaintained. Use `google-re2`.\n\nThere are also other unofficial wrappers:\n\n- A C wrapper is at \u003chttps://github.com/marcomaggi/cre2/\u003e.\n- A D wrapper is at \u003chttps://github.com/ShigekiKarita/re2d/\u003e and [on DUB](https://code.dlang.org/packages/re2d).\n- An Erlang wrapper is at \u003chttps://github.com/dukesoferl/re2/\u003e and [on Hex](https://hex.pm/packages/re2).\n- An Inferno wrapper is at \u003chttps://github.com/powerman/inferno-re2/\u003e.\n- A Node.js wrapper is at \u003chttps://github.com/uhop/node-re2/\u003e and [on NPM](https://www.npmjs.com/package/re2).\n- An OCaml wrapper is at \u003chttps://github.com/janestreet/re2/\u003e and [on OPAM](https://opam.ocaml.org/packages/re2/).\n- A Perl wrapper is at \u003chttps://github.com/dgl/re-engine-RE2/\u003e and [on CPAN](https://metacpan.org/pod/re::engine::RE2).\n- An R wrapper is at \u003chttps://github.com/girishji/re2/\u003e and [on CRAN](https://cran.r-project.org/web/packages/re2/index.html).\n- A Ruby wrapper is at \u003chttps://github.com/mudge/re2/\u003e and on RubyGems (rubygems.org).\n- A WebAssembly wrapper is at \u003chttps://github.com/google/re2-wasm/\u003e and on NPM (npmjs.com).\n\n[RE2J](https://github.com/google/re2j) is a port of the RE2 C++ code to pure Java,\nand [RE2JS](https://github.com/le0pard/re2js) is a port of RE2J to JavaScript.\n\nThe [Go `regexp` package](https://go.dev/pkg/regexp)\nand [Rust `regex` crate](https://docs.rs/regex)\ndo not share code with RE2, but they follow the same principles,\naccept the same syntax, and provide the same efficiency guarantees.\n\n### Contact\n\nThe [issue tracker](https://github.com/google/re2/issues) is the best place for discussions.\n\nThere is a [mailing list](https://groups.google.com/group/re2-dev) for keeping up with code changes.\n\nPlease read the [contribution guide](https://github.com/google/re2/wiki/Contribute) before sending changes.\nIn particular, note that RE2 does not use GitHub pull requests.\n","funding_links":[],"categories":["TODO scan for Android support in followings","Regular Expression","C++","\u003ca name=\"cpp\"\u003e\u003c/a\u003eC++","C++ (70)","This repo contains the list of awesome repo present in github. A tribute to the freely available awesome educational resources.","C++ Libraries","Libraries","正则表达式","Regex engines","Projects built with Bazel","Library"],"sub_categories":["Tokenizer","物理学","Source code","Google projects"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fre2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fre2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fre2/lists"}