{"id":13878087,"url":"https://github.com/mudge/re2","last_synced_at":"2026-04-04T21:05:55.440Z","repository":{"id":424873,"uuid":"795488","full_name":"mudge/re2","owner":"mudge","description":"Ruby bindings to RE2, a \"fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python\".","archived":false,"fork":false,"pushed_at":"2025-04-07T08:29:16.000Z","size":638,"stargazers_count":132,"open_issues_count":5,"forks_count":13,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T00:45:14.143Z","etag":null,"topics":["regex","regular-expression","ruby"],"latest_commit_sha":null,"homepage":"http://mudge.name/re2/","language":"Ruby","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/mudge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-DEPENDENCIES.txt","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},"funding":{"github":"mudge"}},"created_at":"2010-07-24T19:22:00.000Z","updated_at":"2025-02-01T05:22:13.000Z","dependencies_parsed_at":"2023-09-22T03:08:32.594Z","dependency_job_id":"71e1fb39-eebf-48bf-92fc-5339595c5fa3","html_url":"https://github.com/mudge/re2","commit_stats":{"total_commits":364,"total_committers":10,"mean_commits":36.4,"dds":0.3214285714285714,"last_synced_commit":"caa907f11354730f8f16c84413267b1067f9e56d"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Fre2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Fre2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Fre2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mudge%2Fre2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mudge","download_url":"https://codeload.github.com/mudge/re2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986274,"owners_count":21194024,"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":["regex","regular-expression","ruby"],"created_at":"2024-08-06T08:01:39.515Z","updated_at":"2026-04-04T21:05:55.429Z","avatar_url":"https://github.com/mudge.png","language":"Ruby","readme":"# re2 - safer regular expressions in Ruby\n\nRuby bindings to [RE2][], a \"fast, safe, thread-friendly alternative to\nbacktracking regular expression engines like those used in PCRE, Perl, and\nPython\".\n\n[![Build Status](https://github.com/mudge/re2/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mudge/re2/actions)\n\n**Current version:** 2.26.1  \n**Bundled RE2 version:** libre2.11 (2025-11-05)  \n\n```ruby\nRE2('h.*o').full_match?(\"hello\")    #=\u003e true\nRE2('e').full_match?(\"hello\")       #=\u003e false\nRE2('h.*o').partial_match?(\"hello\") #=\u003e true\nRE2('e').partial_match?(\"hello\")    #=\u003e true\nRE2('(\\w+):(\\d+)').full_match(\"ruby:1234\")\n#=\u003e #\u003cRE2::MatchData \"ruby:1234\" 1:\"ruby\" 2:\"1234\"\u003e\n```\n\n## Table of Contents\n\n* [Why RE2?](#why-re2)\n* [Usage](#usage)\n    * [Compiling regular expressions](#compiling-regular-expressions)\n    * [Matching interface](#matching-interface)\n    * [Submatch extraction](#submatch-extraction)\n    * [Scanning text incrementally](#scanning-text-incrementally)\n    * [Searching simultaneously](#searching-simultaneously)\n    * [Replacing and extracting](#replacing-and-extracting)\n    * [Escaping](#escaping)\n    * [Encoding](#encoding)\n* [Requirements](#requirements)\n    * [Native gems](#native-gems)\n    * [Verifying the gems](#verifying-the-gems)\n    * [Installing the `ruby` platform gem](#installing-the-ruby-platform-gem)\n    * [Using system libraries](#using-system-libraries)\n* [Thanks](#thanks)\n* [Contact](#contact)\n* [License](#license)\n    * [Dependencies](#dependencies)\n\n## Why RE2?\n\nWhile [recent\nversions](https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/) of\nRuby have improved defences against [regular expression denial of service\n(ReDoS) attacks](https://en.wikipedia.org/wiki/ReDoS), it is still possible for\nusers to craft malicious patterns that take a long time to process by using\nsyntactic features such as [back-references, lookaheads and possessive\nquantifiers](https://bugs.ruby-lang.org/issues/19104#note-3). RE2 aims to\neliminate ReDoS by design:\n\n\u003e **_Safety is RE2's raison d'être._**\n\u003e\n\u003e RE2 was designed and implemented with an explicit goal of being able to\n\u003e handle regular expressions from untrusted users without risk. One of its\n\u003e primary guarantees is that the match time is linear in the length of the\n\u003e input string. It was also written with production concerns in mind: the\n\u003e parser, the compiler and the execution engines limit their memory usage by\n\u003e working within a configurable budget – failing gracefully when exhausted –\n\u003e and they avoid stack overflow by eschewing recursion.\n\n— [Why RE2?](https://github.com/google/re2/wiki/WhyRE2)\n\n## Usage\n\nInstall re2 as a dependency:\n\n```ruby\n# In your Gemfile\ngem \"re2\"\n\n# Or without Bundler\ngem install re2\n```\n\nInclude in your code:\n\n```ruby\nrequire \"re2\"\n```\n\nFull API documentation automatically generated from the latest version is\navailable at https://mudge.name/re2/.\n\nWhile re2 uses the same naming scheme as Ruby's built-in regular expression\nlibrary (with [`Regexp`](https://mudge.name/re2/RE2/Regexp.html) and\n[`MatchData`](https://mudge.name/re2/RE2/MatchData.html)), its API is slightly\ndifferent:\n\n### Compiling regular expressions\n\n\u003e [!WARNING]\n\u003e RE2's regular expression syntax differs from PCRE and Ruby's built-in\n\u003e [`Regexp`](https://docs.ruby-lang.org/en/3.2/Regexp.html) library, see the\n\u003e [official syntax page](https://github.com/google/re2/wiki/Syntax) for more\n\u003e details.\n\nThe core class is [`RE2::Regexp`](https://mudge.name/re2/RE2/Regexp.html) which\ntakes a regular expression as a string and compiles it internally into an `RE2`\nobject. A global function `RE2` is available to concisely compile a new\n`RE2::Regexp`:\n\n```ruby\nre = RE2('(\\w+):(\\d+)')\n#=\u003e #\u003cRE2::Regexp /(\\w+):(\\d+)/\u003e\nre.ok? #=\u003e true\n\nre = RE2('abc)def')\nre.ok?   #=\u003e false\nre.error #=\u003e \"missing ): abc(def\"\n```\n\n\u003e [!TIP]\n\u003e Note the use of *single quotes* when passing the regular expression as\n\u003e a string to `RE2` so that the backslashes aren't interpreted as escapes.\n\nWhen compiling a regular expression, an optional second argument can be used to change RE2's default options, e.g. stop logging syntax and execution errors to stderr with `log_errors`:\n\n```ruby\nRE2('abc)def', log_errors: false)\n```\n\nSee the API documentation for [`RE2::Regexp#initialize`](https://mudge.name/re2/RE2/Regexp.html#initialize-instance_method) for all the available options.\n\n### Matching interface\n\nThere are two main methods for matching: [`RE2::Regexp#full_match?`](https://mudge.name/re2/RE2/Regexp.html#full_match%3F-instance_method) requires the regular expression to match the entire input text, and [`RE2::Regexp#partial_match?`](https://mudge.name/re2/RE2/Regexp.html#partial_match%3F-instance_method) looks for a match for a substring of the input text, returning a boolean to indicate whether a match was successful or not.\n\n```ruby\nRE2('h.*o').full_match?(\"hello\")    #=\u003e true\nRE2('e').full_match?(\"hello\")       #=\u003e false\n\nRE2('h.*o').partial_match?(\"hello\") #=\u003e true\nRE2('e').partial_match?(\"hello\")    #=\u003e true\n```\n\n### Submatch extraction\n\n\u003e [!TIP]\n\u003e Only extract the number of submatches you need as performance is improved\n\u003e with fewer submatches (with the best performance when avoiding submatch\n\u003e extraction altogether).\n\nBoth matching methods have a second form that can extract submatches as [`RE2::MatchData`](https://mudge.name/re2/RE2/MatchData.html) objects: [`RE2::Regexp#full_match`](https://mudge.name/re2/RE2/Regexp.html#full_match-instance_method) and [`RE2::Regexp#partial_match`](https://mudge.name/re2/RE2/Regexp.html#partial_match-instance_method).\n\n```ruby\nm = RE2('(\\w+):(\\d+)').full_match(\"ruby:1234\")\n#=\u003e #\u003cRE2::MatchData \"ruby:1234\" 1:\"ruby\" 2:\"1234\"\u003e\n\nm[0] #=\u003e \"ruby:1234\"\nm[1] #=\u003e \"ruby\"\nm[2] #=\u003e \"1234\"\n\nm = RE2('(\\w+):(\\d+)').full_match(\"r\")\n#=\u003e nil\n```\n\n`RE2::MatchData` supports retrieving submatches by numeric index or by name if present in the regular expression:\n\n```ruby\nm = RE2('(?P\u003cword\u003e\\w+):(?P\u003cnumber\u003e\\d+)').full_match(\"ruby:1234\")\n#=\u003e #\u003cRE2::MatchData \"ruby:1234\" 1:\"ruby\" 2:\"1234\"\u003e\n\nm[\"word\"]   #=\u003e \"ruby\"\nm[\"number\"] #=\u003e \"1234\"\n```\n\nMultiple submatches can be retrieved at the same time by numeric index or name with [`values_at`](https://mudge.name/re2/RE2/MatchData.html#values_at-instance_method):\n\n```ruby\nm = RE2('(?P\u003cword\u003e\\w+):(?P\u003cnumber\u003e\\d+):(\\d+)').full_match(\"ruby:1234:5678\")\n#=\u003e #\u003cRE2::MatchData \"ruby:1234:5678\" 1:\"ruby\" 2:\"1234\" 3:\"5678\"\u003e\n\nm.values_at(\"word\", :number, 3)\n#=\u003e [\"ruby\", \"1234\", \"5678\"]\n```\n\nAll captures can be returned as an array with [`captures`](https://mudge.name/re2/RE2/MatchData.html#captures-instance_method):\n\n```ruby\nm = RE2('(?P\u003cword\u003e\\w+):(?P\u003cnumber\u003e\\d+):(\\d+)').full_match(\"ruby:1234:5678\")\n#=\u003e #\u003cRE2::MatchData \"ruby:1234:5678\" 1:\"ruby\" 2:\"1234\" 3:\"5678\"\u003e\n\nm.captures #=\u003e [\"ruby\", \"1234\", \"5678\"]\n```\n\nCapturing group names are available on both `RE2::Regexp` and `RE2::MatchData`:\n\n```ruby\nre = RE2('(?P\u003cword\u003e\\w+):(?P\u003cnumber\u003e\\d+):(\\d+)')\nre.names           #=\u003e [\"number\", \"word\"]\n\nm = re.full_match(\"ruby:1234:5678\")\nm.names            #=\u003e [\"number\", \"word\"]\n```\n\nNamed captures can be returned as a hash with [`named_captures`](https://mudge.name/re2/RE2/MatchData.html#named_captures-instance_method):\n\n```ruby\nm = RE2('(?P\u003cword\u003e\\w+):(?P\u003cnumber\u003e\\d+):(\\d+)').full_match(\"ruby:1234:5678\")\n#=\u003e #\u003cRE2::MatchData \"ruby:1234:5678\" 1:\"ruby\" 2:\"1234\" 3:\"5678\"\u003e\n\nm.named_captures\n#=\u003e {\"number\" =\u003e \"1234\", \"word\" =\u003e \"ruby\"}\nm.named_captures(symbolize_names: true)\n#=\u003e {number: \"1234\", word: \"ruby\"}\n```\n\nThis is [also available](https://mudge.name/re2/RE2/Regexp.html#named_captures-instance_method) on the original `RE2::Regexp` but will return the corresponding numerical index for each group:\n\n```ruby\nre = RE2('(?P\u003cword\u003e\\w+):(?P\u003cnumber\u003e\\d+):(\\d+)')\nre.named_captures\n#=\u003e {\"number\" =\u003e 2, \"word\" =\u003e 1}\n```\n\nThe strings before and after a match can be returned with [`pre_match`](https://mudge.name/re2/RE2/MatchData.html#pre_match-instance_method) and [`post_match`](https://mudge.name/re2/RE2/MatchData.html#post_match-instance_method):\n\n```ruby\nm = RE2::Regexp.new('(\\d+)').partial_match(\"bob 123 456\")\nm.pre_match  #=\u003e \"bob \"\nm.post_match #=\u003e \" 456\"\n```\n\nThe [`offset`](https://mudge.name/re2/RE2/MatchData.html#offset-instance_method) and [`match_length`](https://mudge.name/re2/RE2/MatchData.html#match_length-instance_method) of a match can be retrieved by index or name:\n\n```ruby\nm = RE2::Regexp.new('(\\d+)').partial_match(\"bob 123 456\")\nm.offset(1)       #=\u003e [4, 7]\nm.match_length(1) #=\u003e 3\n```\n\n`RE2::MatchData` objects can also be used with Ruby's [pattern matching](https://docs.ruby-lang.org/en/3.2/syntax/pattern_matching_rdoc.html):\n\n```ruby\ncase RE2('(\\w+):(\\d+)').full_match(\"ruby:1234\")\nin [word, number]\n  puts \"Word: #{word}, Number: #{number}\"\nelse\n  puts \"No match\"\nend\n# Word: ruby, Number: 1234\n\ncase RE2('(?P\u003cword\u003e\\w+):(?P\u003cnumber\u003e\\d+)').full_match(\"ruby:1234\")\nin word:, number:\n  puts \"Word: #{word}, Number: #{number}\"\nelse\n  puts \"No match\"\nend\n# Word: ruby, Number: 1234\n```\n\nBy default, both `full_match` and `partial_match` will extract all submatches into the `RE2::MatchData` based on the number of capturing groups in the regular expression. This can be changed by passing an optional second argument when matching:\n\n```ruby\nm = RE2('(\\w+):(\\d+)').full_match(\"ruby:1234\", submatches: 1)\n=\u003e #\u003cRE2::MatchData \"ruby:1234\" 1:\"ruby\"\u003e\n```\n\n\u003e [!WARNING]\n\u003e If the regular expression has no capturing groups or you pass `submatches:\n\u003e 0`, the matching method will behave like its `full_match?` or\n\u003e `partial_match?` form and only return `true` or `false` rather than\n\u003e `RE2::MatchData`.\n\n### Scanning text incrementally\n\nIf you want to repeatedly match regular expressions from the start of some input text, you can use [`RE2::Regexp#scan`](https://mudge.name/re2/RE2/Regexp.html#scan-instance_method) to return an `Enumerable` [`RE2::Scanner`](https://mudge.name/re2/RE2/Scanner.html) object which will lazily consume matches as you iterate over it:\n\n```ruby\nscanner = RE2('(\\w+)').scan(\" one two three 4\")\nscanner.each do |match|\n  puts match.inspect\nend\n# [\"one\"]\n# [\"two\"]\n# [\"three\"]\n# [\"4\"]\n```\n\n### Searching simultaneously\n\n[`RE2::Set`](https://mudge.name/re2/RE2/Set.html) represents a collection of\nregular expressions that can be searched for simultaneously. Calling\n[`RE2::Set#add`](https://mudge.name/re2/RE2/Set.html#add-instance_method) with\na regular expression will return the integer index at which it is stored within\nthe set. After all patterns have been added, the set can be compiled using\n[`RE2::Set#compile`](https://mudge.name/re2/RE2/Set.html#compile-instance_method),\nand then\n[`RE2::Set#match`](https://mudge.name/re2/RE2/Set.html#match-instance_method)\nwill return an array containing the indices of all the patterns that matched.\n[`RE2::Set#size`](https://mudge.name/re2/RE2/Set.html#size-instance_method)\nwill return the number of patterns in the set.\n\n```ruby\nset = RE2::Set.new\nset.add(\"abc\")         #=\u003e 0\nset.add(\"def\")         #=\u003e 1\nset.add(\"ghi\")         #=\u003e 2\nset.size               #=\u003e 3\nset.compile            #=\u003e true\nset.match(\"abcdefghi\") #=\u003e [0, 1, 2]\nset.match(\"ghidefabc\") #=\u003e [2, 1, 0]\n```\n\n### Replacing and extracting\n\n[`RE2.replace`](https://mudge.name/re2/RE2.html#replace-class_method) returns a copy of a given string with the first occurrence of a pattern replaced with a given rewrite string:\n\n```ruby\nRE2.replace(\"hello there\", \"hello\", \"howdy\") #=\u003e \"howdy there\"\n```\n\nThe pattern can be given as either a string or an `RE2::Regexp`:\n\n```ruby\nre = RE2('hel+o')\nRE2.replace(\"hello there\", re, \"yo\") #=\u003e \"yo there\"\n```\n\nTo replace _all_ matches and not just the first, use [`RE2.global_replace`](https://mudge.name/re2/RE2.html#global_replace-class_method):\n\n```ruby\nRE2.global_replace(\"hallo thare\", \"a\", \"e\")  #=\u003e \"hello there\"\n```\n\nTo extract matches with a given rewrite string including substitutions, use [`RE2.extract`](https://mudge.name/re2/RE2.html#extract-class_method):\n\n```ruby\nRE2.extract(\"alice@example.com\", '(\\w+)@(\\w+)', '\\2-\\1')\n#=\u003e \"example-alice\"\n```\n\n### Escaping\n\nTo escape all potentially meaningful regexp characters in a string, use [`RE2.escape`](https://mudge.name/re2/RE2.html#escape-class_method):\n\n```ruby\nRE2.escape(\"1.5-2.0?\") #=\u003e \"1\\\\.5\\\\-2\\\\.0\\\\?\"\n```\n\n### Encoding\n\n\u003e [!WARNING]\n\u003e Note RE2 only supports UTF-8 and ISO-8859-1 encoding so strings will be\n\u003e returned in UTF-8 by default or ISO-8859-1 if the `:utf8` option for the\n\u003e `RE2::Regexp` is set to `false` (any other encoding's behaviour is undefined).\n\nFor backward compatibility: re2 won't automatically convert string inputs to\nthe right encoding so this is the responsibility of the caller, e.g.\n\n```ruby\n# By default, RE2 will process patterns and text as UTF-8\nRE2(non_utf8_pattern.encode(\"UTF-8\")).partial_match(non_utf8_text.encode(\"UTF-8\"))\n\n# If the :utf8 option is false, RE2 will process patterns and text as ISO-8859-1\nRE2(non_latin1_pattern.encode(\"ISO-8859-1\"), utf8: false).partial_match(non_latin1_text.encode(\"ISO-8859-1\"))\n```\n\n## Requirements\n\nThis gem requires the following to run:\n\n* [Ruby](https://www.ruby-lang.org/en/) 3.1 to 4.0\n\nIt supports the following RE2 ABI versions:\n\n* libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to 2025-11-05)\n\n### Native gems\n\nWhere possible, a pre-compiled native gem will be provided for the following platforms:\n\n* Linux\n    * `aarch64-linux`, `arm-linux`, and `x86_64-linux` (requires [glibc](https://www.gnu.org/software/libc/) 2.29+, RubyGems 3.3.22+ and Bundler 2.3.21+)\n    * [musl](https://musl.libc.org/)-based systems such as [Alpine](https://alpinelinux.org) are supported with Bundler 2.5.6+\n* macOS 10.14+ `x86_64-darwin` and `arm64-darwin`\n* Windows 2022+ `x64-mingw-ucrt`\n\n### Verifying the gems\n\nSHA256 checksums are included in the [release notes](https://github.com/mudge/re2/releases) for each version and can be checked with `sha256sum`, e.g.\n\n```console\n$ gem fetch re2 -v 2.18.0\nFetching re2-2.18.0-arm64-darwin.gem\nDownloaded re2-2.18.0-arm64-darwin\n$ sha256sum re2-2.18.0-arm64-darwin.gem\n953063f0491420163d3484ed256fe2ff616c777ec66ee20aa5ec1a1a1fc39ff5  re2-2.18.0-arm64-darwin.gem\n```\n\n[GPG](https://www.gnupg.org/) signatures are attached to each release (the assets ending in `.sig`) and can be verified if you import [our signing key `0x39AC3530070E0F75`](https://mudge.name/39AC3530070E0F75.asc) (or fetch it from a public keyserver, e.g. `gpg --keyserver keyserver.ubuntu.com --recv-key 0x39AC3530070E0F75`):\n\n```console\n$ gpg --verify re2-2.18.0-arm64-darwin.gem.sig re2-2.18.0-arm64-darwin.gem\ngpg: Signature made Sun  3 Aug 11:02:26 2025 BST\ngpg:                using RSA key 702609D9C790F45B577D7BEC39AC3530070E0F75\ngpg: Good signature from \"Paul Mucur \u003cmudge@mudge.name\u003e\" [unknown]\ngpg:                 aka \"Paul Mucur \u003cpaul@ghostcassette.com\u003e\" [unknown]\ngpg: WARNING: This key is not certified with a trusted signature!\ngpg:          There is no indication that the signature belongs to the owner.\nPrimary key fingerprint: 7026 09D9 C790 F45B 577D  7BEC 39AC 3530 070E 0F75\n```\n\nThe fingerprint should be as shown above or you can independently verify it with the ones shown in the footer of https://mudge.name.\n\n### Installing the `ruby` platform gem\n\n\u003e [!WARNING]\n\u003e We strongly recommend using the native gems where possible to avoid the need\n\u003e for compiling the C++ extension and its dependencies which will take longer\n\u003e and be less reliable.\n\nIf you wish to compile the gem, you will need to explicitly install the `ruby` platform gem:\n\n```ruby\n# In your Gemfile with Bundler 2.3.18+\ngem \"re2\", force_ruby_platform: true\n\n# With Bundler 2.1+\nbundle config set force_ruby_platform true\n\n# With older versions of Bundler\nbundle config force_ruby_platform true\n\n# Without Bundler\ngem install re2 --platform=ruby\n```\n\nYou will need a full compiler toolchain for compiling Ruby C extensions (see\n[Nokogiri's \"The Compiler\nToolchain\"](https://nokogiri.org/tutorials/installing_nokogiri.html#appendix-a-the-compiler-toolchain))\nplus the toolchain required for compiling the vendored version of RE2 and its\ndependency [Abseil][] which includes [CMake](https://cmake.org), a compiler\nwith C++17 support such as [clang](http://clang.llvm.org/) 5 or\n[gcc](https://gcc.gnu.org/) 8 and a recent version of\n[pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/). On\nWindows, you'll also need pkgconf 2.1.0+ to avoid [`undefined reference`\nerrors](https://github.com/pkgconf/pkgconf/issues/322) when attempting to\ncompile Abseil.\n\n### Using system libraries\n\nIf you already have RE2 installed, you can instruct the gem not to use its own vendored version:\n\n```ruby\ngem install re2 --platform=ruby -- --enable-system-libraries\n\n# If RE2 is not installed in /usr/local, /usr, or /opt/homebrew:\ngem install re2 --platform=ruby -- --enable-system-libraries --with-re2-dir=/path/to/re2/prefix\n```\n\nAlternatively, you can set the `RE2_USE_SYSTEM_LIBRARIES` environment variable instead of passing `--enable-system-libraries` to the `gem` command.\n\n\n## Thanks\n\n* Thanks to [Jason Woods](https://github.com/driskell) who contributed the\n  original implementations of `RE2::MatchData#begin` and `RE2::MatchData#end`.\n* Thanks to [Stefano Rivera](https://github.com/stefanor) who first contributed\n  C++11 support.\n* Thanks to [Stan Hu](https://github.com/stanhu) for reporting a bug with empty\n  patterns and `RE2::Regexp#scan`, contributing support for libre2.11\n  (2023-07-01) and for vendoring RE2 and abseil and compiling native gems in\n  2.0.\n* Thanks to [Sebastian Reitenbach](https://github.com/buzzdeee) for reporting\n  the deprecation and removal of the `utf8` encoding option in RE2.\n* Thanks to [Sergio Medina](https://github.com/serch) for reporting a bug when\n  using `RE2::Scanner#scan` with an invalid regular expression.\n* Thanks to [Pritam Baral](https://github.com/pritambaral) for contributing the\n  initial support for `RE2::Set`.\n* Thanks to [Mike Dalessio](https://github.com/flavorjones) for reviewing the\n  precompilation of native gems in 2.0.\n* Thanks to [Peter Zhu](https://github.com/peterzhu2118) for\n  [ruby_memcheck](https://github.com/Shopify/ruby_memcheck) and helping find\n  the memory leaks fixed in 2.1.3.\n* Thanks to [Jean Boussier](https://github.com/byroot) for contributing the\n  switch to Ruby's `TypedData` API and the resulting garbage collection\n  improvements in 2.4.0.\n* Thanks to [Manuel Jacob](https://github.com/manueljacob) for reporting a bug\n  when passing strings with null bytes.\n* Thanks to [Maciej Gajewski](https://github.com/konieczkow) for helping\n  confirm issues with GC compaction and mutable strings.\n\n## Contact\n\nAll issues and suggestions should go to [GitHub Issues](https://github.com/mudge/re2/issues).\n\n## License\n\nThis library is licensed under the BSD 3-Clause License, see `LICENSE.txt`.\n\nCopyright © 2010, Paul Mucur.\n\n### Dependencies\n\nThe source code of [RE2][] is distributed in the `ruby` platform gem. This code is licensed under the BSD 3-Clause License, see `LICENSE-DEPENDENCIES.txt`.\n\nThe source code of [Abseil][] is distributed in the `ruby` platform gem. This code is licensed under the Apache License 2.0, see `LICENSE-DEPENDENCIES.txt`.\n\n  [RE2]: https://github.com/google/re2\n  [Abseil]: https://abseil.io\n","funding_links":["https://github.com/sponsors/mudge"],"categories":["Ruby","Language Aware String Manipulation"],"sub_categories":["Text-to-Speech-to-Text"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmudge%2Fre2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmudge%2Fre2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmudge%2Fre2/lists"}