re2 2.4.3-arm-linux → 2.6.0-arm-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +278 -191
 - data/Rakefile +1 -1
 - data/ext/re2/extconf.rb +6 -70
 - data/ext/re2/re2.cc +450 -263
 - data/ext/re2/recipes.rb +8 -0
 - data/lib/2.6/re2.so +0 -0
 - data/lib/2.7/re2.so +0 -0
 - data/lib/3.0/re2.so +0 -0
 - data/lib/3.1/re2.so +0 -0
 - data/lib/3.2/re2.so +0 -0
 - data/lib/3.3/re2.so +0 -0
 - data/lib/re2/regexp.rb +70 -0
 - data/lib/re2/scanner.rb +9 -0
 - data/lib/re2/string.rb +10 -59
 - data/lib/re2/version.rb +10 -1
 - data/lib/re2.rb +7 -3
 - data/re2.gemspec +3 -2
 - data/spec/kernel_spec.rb +2 -2
 - data/spec/re2/match_data_spec.rb +64 -25
 - data/spec/re2/regexp_spec.rb +492 -113
 - data/spec/re2/scanner_spec.rb +3 -8
 - data/spec/re2/set_spec.rb +18 -18
 - data/spec/re2_spec.rb +4 -4
 - metadata +9 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 75fd241317d5b71585653e0cfbd355dbc7a121e9aa5b930d3501c26fa02d6a4e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 74f249cbf03ca05344b53206277eff97030c5d4432a4358745ab50fa252eaab9
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 3e44a97ad5614ddb5a5a321530b2b2cdcfd0dd330b92277adfb69dfb477e87c5e338394304c94e298bb78f2bf5f8710650dfa37d296e1c71b0d22746f10a92d5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0435e54961edd7a0ca238ad79e4512714d79c2af4f1f4a061f6e82d47b36e5e58e13881159df35eb5becdd3a74a90dcfb315304b46de0c9f0836a7ce8bf7de22
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,205 +1,246 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            re2  
     | 
| 
       2 
     | 
    
         
            -
            ===
         
     | 
| 
      
 1 
     | 
    
         
            +
            # re2 - safer regular expressions in Ruby
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            Ruby bindings to [RE2][], a "fast, safe, thread-friendly alternative to
         
     | 
| 
       5 
4 
     | 
    
         
             
            backtracking regular expression engines like those used in PCRE, Perl, and
         
     | 
| 
       6 
5 
     | 
    
         
             
            Python".
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            [](https://github.com/mudge/re2/actions)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            **Current version:** 2.6.0  
         
     | 
| 
       10 
10 
     | 
    
         
             
            **Bundled RE2 version:** libre2.11 (2023-11-01)  
         
     | 
| 
       11 
     | 
    
         
            -
            **Supported RE2 versions:** libre2.0 (< 2020-03-02), libre2.1 (2020-03-02), libre2.6 (2020-03-03), libre2.7 (2020-05-01), libre2.8 (2020-07-06), libre2.9 (2020-11-01), libre2.10 (2022-12-01), libre2.11 (2023-07-01)
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 13 
     | 
    
         
            +
            RE2('h.*o').full_match?("hello")    #=> true
         
     | 
| 
      
 14 
     | 
    
         
            +
            RE2('e').full_match?("hello")       #=> false
         
     | 
| 
      
 15 
     | 
    
         
            +
            RE2('h.*o').partial_match?("hello") #=> true
         
     | 
| 
      
 16 
     | 
    
         
            +
            RE2('e').partial_match?("hello")    #=> true
         
     | 
| 
      
 17 
     | 
    
         
            +
            RE2('(\w+):(\d+)').full_match("ruby:1234")
         
     | 
| 
      
 18 
     | 
    
         
            +
            #=> #<RE2::MatchData "ruby:1234" 1:"ruby" 2:"1234">
         
     | 
| 
      
 19 
     | 
    
         
            +
            ```
         
     | 
| 
       15 
20 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
            ## Table of Contents
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            * [Why RE2?](#why-re2)
         
     | 
| 
      
 24 
     | 
    
         
            +
            * [Usage](#usage)
         
     | 
| 
      
 25 
     | 
    
         
            +
                * [Compiling regular expressions](#compiling-regular-expressions)
         
     | 
| 
      
 26 
     | 
    
         
            +
                * [Matching interface](#matching-interface)
         
     | 
| 
      
 27 
     | 
    
         
            +
                * [Submatch extraction](#submatch-extraction)
         
     | 
| 
      
 28 
     | 
    
         
            +
                * [Scanning text incrementally](#scanning-text-incrementally)
         
     | 
| 
      
 29 
     | 
    
         
            +
                * [Searching simultaneously](#searching-simultaneously)
         
     | 
| 
      
 30 
     | 
    
         
            +
                * [Encoding](#encoding)
         
     | 
| 
      
 31 
     | 
    
         
            +
            * [Requirements](#requirements)
         
     | 
| 
      
 32 
     | 
    
         
            +
                * [Native gems](#native-gems)
         
     | 
| 
      
 33 
     | 
    
         
            +
                * [Verifying the gems](#verifying-the-gems)
         
     | 
| 
      
 34 
     | 
    
         
            +
                * [Installing the `ruby` platform gem](#installing-the-ruby-platform-gem)
         
     | 
| 
      
 35 
     | 
    
         
            +
                * [Using system libraries](#using-system-libraries)
         
     | 
| 
      
 36 
     | 
    
         
            +
            * [Thanks](#thanks)
         
     | 
| 
      
 37 
     | 
    
         
            +
            * [Contact](#contact)
         
     | 
| 
      
 38 
     | 
    
         
            +
            * [License](#license)
         
     | 
| 
      
 39 
     | 
    
         
            +
                * [Dependencies](#dependencies)
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            ## Why RE2?
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            While [recent
         
     | 
| 
      
 44 
     | 
    
         
            +
            versions](https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/) of
         
     | 
| 
      
 45 
     | 
    
         
            +
            Ruby have improved defences against [regular expression denial of service
         
     | 
| 
      
 46 
     | 
    
         
            +
            (ReDoS) attacks](https://en.wikipedia.org/wiki/ReDoS), it is still possible for
         
     | 
| 
      
 47 
     | 
    
         
            +
            users to craft malicious patterns that take a long time to process by using
         
     | 
| 
      
 48 
     | 
    
         
            +
            syntactic features such as [back-references, lookaheads and possessive
         
     | 
| 
      
 49 
     | 
    
         
            +
            quantifiers](https://bugs.ruby-lang.org/issues/19104#note-3). RE2 aims to
         
     | 
| 
      
 50 
     | 
    
         
            +
            eliminate ReDoS by design:
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            > **_Safety is RE2's raison d'être._**
         
     | 
| 
      
 53 
     | 
    
         
            +
            >
         
     | 
| 
      
 54 
     | 
    
         
            +
            > RE2 was designed and implemented with an explicit goal of being able to
         
     | 
| 
      
 55 
     | 
    
         
            +
            > handle regular expressions from untrusted users without risk. One of its
         
     | 
| 
      
 56 
     | 
    
         
            +
            > primary guarantees is that the match time is linear in the length of the
         
     | 
| 
      
 57 
     | 
    
         
            +
            > input string. It was also written with production concerns in mind: the
         
     | 
| 
      
 58 
     | 
    
         
            +
            > parser, the compiler and the execution engines limit their memory usage by
         
     | 
| 
      
 59 
     | 
    
         
            +
            > working within a configurable budget – failing gracefully when exhausted –
         
     | 
| 
      
 60 
     | 
    
         
            +
            > and they avoid stack overflow by eschewing recursion.
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            — [Why RE2?](https://github.com/google/re2/wiki/WhyRE2)
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            Install re2 as a dependency:
         
     | 
| 
       19 
67 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 69 
     | 
    
         
            +
            # In your Gemfile
         
     | 
| 
      
 70 
     | 
    
         
            +
            gem "re2"
         
     | 
| 
       22 
71 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            - `x64-mingw32` / `x64-mingw-ucrt`
         
     | 
| 
       27 
     | 
    
         
            -
            - `x86-linux` (requires: glibc >= 2.17)
         
     | 
| 
       28 
     | 
    
         
            -
            - `x86_64-darwin`
         
     | 
| 
       29 
     | 
    
         
            -
            - `x86_64-linux` (requires: glibc >= 2.17)
         
     | 
| 
      
 72 
     | 
    
         
            +
            # Or without Bundler
         
     | 
| 
      
 73 
     | 
    
         
            +
            gem install re2
         
     | 
| 
      
 74 
     | 
    
         
            +
            ```
         
     | 
| 
       30 
75 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            installed as well as a C++ compiler such as [gcc][] (on Debian and Ubuntu, this
         
     | 
| 
       33 
     | 
    
         
            -
            is provided by the [build-essential][] package). If you are using macOS, I
         
     | 
| 
       34 
     | 
    
         
            -
            recommend installing RE2 with [Homebrew][] by running the following:
         
     | 
| 
      
 76 
     | 
    
         
            +
            Include in your code:
         
     | 
| 
       35 
77 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 78 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 79 
     | 
    
         
            +
            require "re2"
         
     | 
| 
      
 80 
     | 
    
         
            +
            ```
         
     | 
| 
       37 
81 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 82 
     | 
    
         
            +
            Full API documentation automatically generated from the latest version is
         
     | 
| 
      
 83 
     | 
    
         
            +
            available at https://mudge.name/re2/.
         
     | 
| 
       39 
84 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 85 
     | 
    
         
            +
            While re2 uses the same naming scheme as Ruby's built-in regular expression
         
     | 
| 
      
 86 
     | 
    
         
            +
            library (with [`Regexp`](https://mudge.name/re2/RE2/Regexp.html) and
         
     | 
| 
      
 87 
     | 
    
         
            +
            [`MatchData`](https://mudge.name/re2/RE2/MatchData.html)), its API is slightly
         
     | 
| 
      
 88 
     | 
    
         
            +
            different:
         
     | 
| 
       41 
89 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            C++14 support such as [clang](http://clang.llvm.org/) 3.4 or
         
     | 
| 
       44 
     | 
    
         
            -
            [gcc](https://gcc.gnu.org/) 5.
         
     | 
| 
      
 90 
     | 
    
         
            +
            ### Compiling regular expressions
         
     | 
| 
       45 
91 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
            > [!WARNING]
         
     | 
| 
      
 93 
     | 
    
         
            +
            > RE2's regular expression syntax differs from PCRE and Ruby's built-in
         
     | 
| 
      
 94 
     | 
    
         
            +
            > [`Regexp`](https://docs.ruby-lang.org/en/3.2/Regexp.html) library, see the
         
     | 
| 
      
 95 
     | 
    
         
            +
            > [official syntax page](https://github.com/google/re2/wiki/Syntax) for more
         
     | 
| 
      
 96 
     | 
    
         
            +
            > details.
         
     | 
| 
       49 
97 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 98 
     | 
    
         
            +
            The core class is [`RE2::Regexp`](https://mudge.name/re2/RE2/Regexp.html) which
         
     | 
| 
      
 99 
     | 
    
         
            +
            takes a regular expression as a string and compiles it internally into an `RE2`
         
     | 
| 
      
 100 
     | 
    
         
            +
            object. A global function `RE2` is available to concisely compile a new
         
     | 
| 
      
 101 
     | 
    
         
            +
            `RE2::Regexp`:
         
     | 
| 
       54 
102 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
      
 103 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 104 
     | 
    
         
            +
            re = RE2('(\w+):(\d+)')
         
     | 
| 
      
 105 
     | 
    
         
            +
            #=> #<RE2::Regexp /(\w+):(\d+)/>
         
     | 
| 
      
 106 
     | 
    
         
            +
            re.ok? #=> true
         
     | 
| 
       58 
107 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
            re = RE2('abc)def')
         
     | 
| 
      
 109 
     | 
    
         
            +
            re.ok?   #=> false
         
     | 
| 
      
 110 
     | 
    
         
            +
            re.error #=> "missing ): abc(def"
         
     | 
| 
      
 111 
     | 
    
         
            +
            ```
         
     | 
| 
       60 
112 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
      
 113 
     | 
    
         
            +
            > [!TIP]
         
     | 
| 
      
 114 
     | 
    
         
            +
            > Note the use of *single quotes* when passing the regular expression as
         
     | 
| 
      
 115 
     | 
    
         
            +
            > a string to `RE2` so that the backslashes aren't interpreted as escapes.
         
     | 
| 
       64 
116 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
            -------------
         
     | 
| 
      
 117 
     | 
    
         
            +
            When 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`:
         
     | 
| 
       67 
118 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
      
 119 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 120 
     | 
    
         
            +
            RE2('abc)def', log_errors: false)
         
     | 
| 
      
 121 
     | 
    
         
            +
            ```
         
     | 
| 
       70 
122 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
            built-in [`Regexp`][Regexp] library, see the [official syntax page][] for more
         
     | 
| 
       73 
     | 
    
         
            -
            details.
         
     | 
| 
      
 123 
     | 
    
         
            +
            See the API documentation for [`RE2::Regexp#initialize`](https://mudge.name/re2/RE2/Regexp.html#initialize-instance_method) for all the available options.
         
     | 
| 
       74 
124 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
            -----
         
     | 
| 
      
 125 
     | 
    
         
            +
            ### Matching interface
         
     | 
| 
       77 
126 
     | 
    
         | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
            library (with [`Regexp`](http://mudge.name/re2/RE2/Regexp.html) and
         
     | 
| 
       80 
     | 
    
         
            -
            [`MatchData`](http://mudge.name/re2/RE2/MatchData.html)), its API is slightly
         
     | 
| 
       81 
     | 
    
         
            -
            different:
         
     | 
| 
      
 127 
     | 
    
         
            +
            There 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.
         
     | 
| 
       82 
128 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
            ``` 
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            => #<RE2::MatchData "w1234" 1:"1" 2:"234">
         
     | 
| 
       90 
     | 
    
         
            -
            > m[1]
         
     | 
| 
       91 
     | 
    
         
            -
            => "1"
         
     | 
| 
       92 
     | 
    
         
            -
            > m.string
         
     | 
| 
       93 
     | 
    
         
            -
            => "w1234"
         
     | 
| 
       94 
     | 
    
         
            -
            > m.begin(1)
         
     | 
| 
       95 
     | 
    
         
            -
            => 1
         
     | 
| 
       96 
     | 
    
         
            -
            > m.end(1)
         
     | 
| 
       97 
     | 
    
         
            -
            => 2
         
     | 
| 
       98 
     | 
    
         
            -
            > r =~ "w1234"
         
     | 
| 
       99 
     | 
    
         
            -
            => true
         
     | 
| 
       100 
     | 
    
         
            -
            > r !~ "bob"
         
     | 
| 
       101 
     | 
    
         
            -
            => true
         
     | 
| 
       102 
     | 
    
         
            -
            > r.match("bob")
         
     | 
| 
       103 
     | 
    
         
            -
            => nil
         
     | 
| 
      
 129 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 130 
     | 
    
         
            +
            RE2('h.*o').full_match?("hello")    #=> true
         
     | 
| 
      
 131 
     | 
    
         
            +
            RE2('e').full_match?("hello")       #=> false
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
            RE2('h.*o').partial_match?("hello") #=> true
         
     | 
| 
      
 134 
     | 
    
         
            +
            RE2('e').partial_match?("hello")    #=> true
         
     | 
| 
       104 
135 
     | 
    
         
             
            ```
         
     | 
| 
       105 
136 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
            [`RE2::Regexp.new`](http://mudge.name/re2/RE2/Regexp.html#initialize-instance_method)
         
     | 
| 
       108 
     | 
    
         
            -
            (or `RE2::Regexp.compile`) can be quite verbose, a helper method has been
         
     | 
| 
       109 
     | 
    
         
            -
            defined against `Kernel` so you can use a shorter version to create regular
         
     | 
| 
       110 
     | 
    
         
            -
            expressions:
         
     | 
| 
      
 137 
     | 
    
         
            +
            ### Submatch extraction
         
     | 
| 
       111 
138 
     | 
    
         | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
            >  
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 139 
     | 
    
         
            +
            > [!TIP]
         
     | 
| 
      
 140 
     | 
    
         
            +
            > Only extract the number of submatches you need as performance is improved
         
     | 
| 
      
 141 
     | 
    
         
            +
            > with fewer submatches (with the best performance when avoiding submatch
         
     | 
| 
      
 142 
     | 
    
         
            +
            > extraction altogether).
         
     | 
| 
       116 
143 
     | 
    
         | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
            in the following example:
         
     | 
| 
      
 144 
     | 
    
         
            +
            Both 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).
         
     | 
| 
       119 
145 
     | 
    
         | 
| 
       120 
     | 
    
         
            -
            ``` 
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 146 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 147 
     | 
    
         
            +
            m = RE2('(\w+):(\d+)').full_match("ruby:1234")
         
     | 
| 
      
 148 
     | 
    
         
            +
            #=> #<RE2::MatchData "ruby:1234" 1:"ruby" 2:"1234">
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
            m[0] #=> "ruby:1234"
         
     | 
| 
      
 151 
     | 
    
         
            +
            m[1] #=> "ruby"
         
     | 
| 
      
 152 
     | 
    
         
            +
            m[2] #=> "1234"
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
            m = RE2('(\w+):(\d+)').full_match("r")
         
     | 
| 
      
 155 
     | 
    
         
            +
            #=> nil
         
     | 
| 
       123 
156 
     | 
    
         
             
            ```
         
     | 
| 
       124 
157 
     | 
    
         | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 158 
     | 
    
         
            +
            `RE2::MatchData` supports retrieving submatches by numeric index or by name if present in the regular expression:
         
     | 
| 
       126 
159 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
            ``` 
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
            => "Bob"
         
     | 
| 
       134 
     | 
    
         
            -
            > m["age"]
         
     | 
| 
       135 
     | 
    
         
            -
            => "40"
         
     | 
| 
      
 160 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 161 
     | 
    
         
            +
            m = RE2('(?P<word>\w+):(?P<number>\d+)').full_match("ruby:1234")
         
     | 
| 
      
 162 
     | 
    
         
            +
            #=> #<RE2::MatchData "ruby:1234" 1:"ruby" 2:"1234">
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
            m["word"]   #=> "ruby"
         
     | 
| 
      
 165 
     | 
    
         
            +
            m["number"] #=> "1234"
         
     | 
| 
       136 
166 
     | 
    
         
             
            ```
         
     | 
| 
       137 
167 
     | 
    
         | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
            matches (similar in purpose to Ruby's
         
     | 
| 
       140 
     | 
    
         
            -
            [`String#scan`](http://ruby-doc.org/core-2.0.0/String.html#method-i-scan)).
         
     | 
| 
       141 
     | 
    
         
            -
            Calling `scan` will return an `RE2::Scanner` which is
         
     | 
| 
       142 
     | 
    
         
            -
            [enumerable](http://ruby-doc.org/core-2.0.0/Enumerable.html) meaning you can
         
     | 
| 
       143 
     | 
    
         
            -
            use `each` to iterate through the matches (and even use
         
     | 
| 
       144 
     | 
    
         
            -
            [`Enumerator::Lazy`](http://ruby-doc.org/core-2.0/Enumerator/Lazy.html)):
         
     | 
| 
      
 168 
     | 
    
         
            +
            They can also be used with Ruby's [pattern matching](https://docs.ruby-lang.org/en/3.2/syntax/pattern_matching_rdoc.html):
         
     | 
| 
       145 
169 
     | 
    
         | 
| 
       146 
170 
     | 
    
         
             
            ```ruby
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
      
 171 
     | 
    
         
            +
            case RE2('(\w+):(\d+)').full_match("ruby:1234")
         
     | 
| 
      
 172 
     | 
    
         
            +
            in [word, number]
         
     | 
| 
      
 173 
     | 
    
         
            +
              puts "Word: #{word}, Number: #{number}"
         
     | 
| 
      
 174 
     | 
    
         
            +
            else
         
     | 
| 
      
 175 
     | 
    
         
            +
              puts "No match"
         
     | 
| 
       151 
176 
     | 
    
         
             
            end
         
     | 
| 
      
 177 
     | 
    
         
            +
            # Word: ruby, Number: 1234
         
     | 
| 
       152 
178 
     | 
    
         | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
      
 179 
     | 
    
         
            +
            case RE2('(?P<word>\w+):(?P<number>\d+)').full_match("ruby:1234")
         
     | 
| 
      
 180 
     | 
    
         
            +
            in word:, number:
         
     | 
| 
      
 181 
     | 
    
         
            +
              puts "Word: #{word}, Number: #{number}"
         
     | 
| 
      
 182 
     | 
    
         
            +
            else
         
     | 
| 
      
 183 
     | 
    
         
            +
              puts "No match"
         
     | 
| 
      
 184 
     | 
    
         
            +
            end
         
     | 
| 
      
 185 
     | 
    
         
            +
            # Word: ruby, Number: 1234
         
     | 
| 
       158 
186 
     | 
    
         
             
            ```
         
     | 
| 
       159 
187 
     | 
    
         | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
            string. Calling `RE2::Set#add` with a pattern will return an integer index of
         
     | 
| 
       162 
     | 
    
         
            -
            the pattern. After all patterns have been added, the set can be compiled using
         
     | 
| 
       163 
     | 
    
         
            -
            `RE2::Set#compile`, and then `RE2::Set#match` will return an `Array<Integer>`
         
     | 
| 
       164 
     | 
    
         
            -
            containing the indices of all the patterns that matched.
         
     | 
| 
      
 188 
     | 
    
         
            +
            By 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:
         
     | 
| 
       165 
189 
     | 
    
         | 
| 
       166 
190 
     | 
    
         
             
            ```ruby
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
            set.add("def") #=> 1
         
     | 
| 
       170 
     | 
    
         
            -
            set.add("ghi") #=> 2
         
     | 
| 
       171 
     | 
    
         
            -
            set.compile #=> true
         
     | 
| 
       172 
     | 
    
         
            -
            set.match("abcdefghi") #=> [0, 1, 2]
         
     | 
| 
       173 
     | 
    
         
            -
            set.match("ghidefabc") #=> [2, 1, 0]
         
     | 
| 
      
 191 
     | 
    
         
            +
            m = RE2('(\w+):(\d+)').full_match("ruby:1234", submatches: 1)
         
     | 
| 
      
 192 
     | 
    
         
            +
            => #<RE2::MatchData "ruby:1234" 1:"ruby">
         
     | 
| 
       174 
193 
     | 
    
         
             
            ```
         
     | 
| 
       175 
194 
     | 
    
         | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
      
 195 
     | 
    
         
            +
            > [!WARNING]
         
     | 
| 
      
 196 
     | 
    
         
            +
            > If the regular expression has no capturing groups or you pass `submatches:
         
     | 
| 
      
 197 
     | 
    
         
            +
            > 0`, the matching method will behave like its `full_match?` or
         
     | 
| 
      
 198 
     | 
    
         
            +
            > `partial_match?` form and only return `true` or `false` rather than
         
     | 
| 
      
 199 
     | 
    
         
            +
            > `RE2::MatchData`.
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
            ### Scanning text incrementally
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            If 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:
         
     | 
| 
       177 
204 
     | 
    
         | 
| 
       178 
205 
     | 
    
         
             
            ```ruby
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
              puts  
     | 
| 
       182 
     | 
    
         
            -
            else
         
     | 
| 
       183 
     | 
    
         
            -
              puts "No match!"
         
     | 
| 
      
 206 
     | 
    
         
            +
            scanner = RE2('(\w+)').scan(" one two three 4")
         
     | 
| 
      
 207 
     | 
    
         
            +
            scanner.each do |match|
         
     | 
| 
      
 208 
     | 
    
         
            +
              puts match.inspect
         
     | 
| 
       184 
209 
     | 
    
         
             
            end
         
     | 
| 
       185 
     | 
    
         
            -
            #  
     | 
| 
      
 210 
     | 
    
         
            +
            # ["one"]
         
     | 
| 
      
 211 
     | 
    
         
            +
            # ["two"]
         
     | 
| 
      
 212 
     | 
    
         
            +
            # ["three"]
         
     | 
| 
      
 213 
     | 
    
         
            +
            # ["4"]
         
     | 
| 
      
 214 
     | 
    
         
            +
            ```
         
     | 
| 
       186 
215 
     | 
    
         | 
| 
      
 216 
     | 
    
         
            +
            ### Searching simultaneously
         
     | 
| 
       187 
217 
     | 
    
         | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
             
     | 
| 
      
 218 
     | 
    
         
            +
            [`RE2::Set`](https://mudge.name/re2/RE2/Set.html) represents a collection of
         
     | 
| 
      
 219 
     | 
    
         
            +
            regular expressions that can be searched for simultaneously. Calling
         
     | 
| 
      
 220 
     | 
    
         
            +
            [`RE2::Set#add`](https://mudge.name/re2/RE2/Set.html#add-instance_method) with
         
     | 
| 
      
 221 
     | 
    
         
            +
            a regular expression will return the integer index at which it is stored within
         
     | 
| 
      
 222 
     | 
    
         
            +
            the set. After all patterns have been added, the set can be compiled using
         
     | 
| 
      
 223 
     | 
    
         
            +
            [`RE2::Set#compile`](https://mudge.name/re2/RE2/Set.html#compile-instance_method),
         
     | 
| 
      
 224 
     | 
    
         
            +
            and then
         
     | 
| 
      
 225 
     | 
    
         
            +
            [`RE2::Set#match`](https://mudge.name/re2/RE2/Set.html#match-instance_method)
         
     | 
| 
      
 226 
     | 
    
         
            +
            will return an array containing the indices of all the patterns that matched.
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 229 
     | 
    
         
            +
            set = RE2::Set.new
         
     | 
| 
      
 230 
     | 
    
         
            +
            set.add("abc")         #=> 0
         
     | 
| 
      
 231 
     | 
    
         
            +
            set.add("def")         #=> 1
         
     | 
| 
      
 232 
     | 
    
         
            +
            set.add("ghi")         #=> 2
         
     | 
| 
      
 233 
     | 
    
         
            +
            set.compile            #=> true
         
     | 
| 
      
 234 
     | 
    
         
            +
            set.match("abcdefghi") #=> [0, 1, 2]
         
     | 
| 
      
 235 
     | 
    
         
            +
            set.match("ghidefabc") #=> [2, 1, 0]
         
     | 
| 
       195 
236 
     | 
    
         
             
            ```
         
     | 
| 
       196 
237 
     | 
    
         | 
| 
       197 
     | 
    
         
            -
            Encoding
         
     | 
| 
       198 
     | 
    
         
            -
            --------
         
     | 
| 
      
 238 
     | 
    
         
            +
            ### Encoding
         
     | 
| 
       199 
239 
     | 
    
         | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
      
 240 
     | 
    
         
            +
            > [!WARNING]
         
     | 
| 
      
 241 
     | 
    
         
            +
            > Note RE2 only supports UTF-8 and ISO-8859-1 encoding so strings will be
         
     | 
| 
      
 242 
     | 
    
         
            +
            > returned in UTF-8 by default or ISO-8859-1 if the `:utf8` option for the
         
     | 
| 
      
 243 
     | 
    
         
            +
            > `RE2::Regexp` is set to `false` (any other encoding's behaviour is undefined).
         
     | 
| 
       203 
244 
     | 
    
         | 
| 
       204 
245 
     | 
    
         
             
            For backward compatibility: re2 won't automatically convert string inputs to
         
     | 
| 
       205 
246 
     | 
    
         
             
            the right encoding so this is the responsibility of the caller, e.g.
         
     | 
| 
         @@ -209,51 +250,106 @@ the right encoding so this is the responsibility of the caller, e.g. 
     | 
|
| 
       209 
250 
     | 
    
         
             
            RE2(non_utf8_pattern.encode("UTF-8")).match(non_utf8_text.encode("UTF-8"))
         
     | 
| 
       210 
251 
     | 
    
         | 
| 
       211 
252 
     | 
    
         
             
            # If the :utf8 option is false, RE2 will process patterns and text as ISO-8859-1
         
     | 
| 
       212 
     | 
    
         
            -
            RE2(non_latin1_pattern.encode("ISO-8859-1"), : 
     | 
| 
      
 253 
     | 
    
         
            +
            RE2(non_latin1_pattern.encode("ISO-8859-1"), utf8: false).match(non_latin1_text.encode("ISO-8859-1"))
         
     | 
| 
      
 254 
     | 
    
         
            +
            ```
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
            ## Requirements
         
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
      
 258 
     | 
    
         
            +
            This gem requires the following to run:
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
            * [Ruby](https://www.ruby-lang.org/en/) 2.6 to 3.3
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
            It supports the following RE2 ABI versions:
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
            * libre2.0 (prior to release 2020-03-02) to libre2.11 (2023-07-01 to 2023-11-01)
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
            ### Native gems
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
            Where possible, a pre-compiled native gem will be provided for the following platforms:
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
            * Linux
         
     | 
| 
      
 271 
     | 
    
         
            +
                * `aarch64-linux` and `arm-linux` (requires [glibc](https://www.gnu.org/software/libc/) 2.29+)
         
     | 
| 
      
 272 
     | 
    
         
            +
                * `x86-linux` and `x86_64-linux` (requires [glibc](https://www.gnu.org/software/libc/) 2.17+)
         
     | 
| 
      
 273 
     | 
    
         
            +
                * [musl](https://musl.libc.org/)-based systems such as [Alpine](https://alpinelinux.org) are supported as long as a [glibc-compatible library is installed](https://wiki.alpinelinux.org/wiki/Running_glibc_programs)
         
     | 
| 
      
 274 
     | 
    
         
            +
            * macOS `x86_64-darwin` and `arm64-darwin`
         
     | 
| 
      
 275 
     | 
    
         
            +
            * Windows `x64-mingw32` and `x64-mingw-ucrt`
         
     | 
| 
      
 276 
     | 
    
         
            +
             
     | 
| 
      
 277 
     | 
    
         
            +
            ### Verifying the gems
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
            SHA256 checksums are included in the [release notes](https://github.com/mudge/re2/releases) for each version and can be checked with `sha256sum`, e.g.
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
            ```console
         
     | 
| 
      
 282 
     | 
    
         
            +
            $ gem fetch re2 -v 2.5.0
         
     | 
| 
      
 283 
     | 
    
         
            +
            Fetching re2-2.5.0-arm64-darwin.gem
         
     | 
| 
      
 284 
     | 
    
         
            +
            Downloaded re2-2.5.0-arm64-darwin
         
     | 
| 
      
 285 
     | 
    
         
            +
            $ sha256sum re2-2.5.0-arm64-darwin.gem
         
     | 
| 
      
 286 
     | 
    
         
            +
            4b20c4539a12787102b22012e678968af23f87e35f88843744835bd13ac9f6bc  re2-2.5.0-arm64-darwin.gem
         
     | 
| 
      
 287 
     | 
    
         
            +
            ```
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
            [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`):
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
            ```console
         
     | 
| 
      
 292 
     | 
    
         
            +
            $ gpg --verify re2-2.5.0-arm64-darwin.gem.sig re2-2.5.0-arm64-darwin.gem
         
     | 
| 
      
 293 
     | 
    
         
            +
            gpg: Signature made Fri 15 Dec 2023 12:58:58 GMT
         
     | 
| 
      
 294 
     | 
    
         
            +
            gpg:                using RSA key 702609D9C790F45B577D7BEC39AC3530070E0F75
         
     | 
| 
      
 295 
     | 
    
         
            +
            gpg: Good signature from "Paul Mucur <mudge@mudge.name>" [unknown]
         
     | 
| 
      
 296 
     | 
    
         
            +
            gpg:                 aka "Paul Mucur <paul@ghostcassette.com>" [unknown]
         
     | 
| 
      
 297 
     | 
    
         
            +
            gpg: WARNING: This key is not certified with a trusted signature!
         
     | 
| 
      
 298 
     | 
    
         
            +
            gpg:          There is no indication that the signature belongs to the owner.
         
     | 
| 
      
 299 
     | 
    
         
            +
            Primary key fingerprint: 7026 09D9 C790 F45B 577D  7BEC 39AC 3530 070E 0F75
         
     | 
| 
       213 
300 
     | 
    
         
             
            ```
         
     | 
| 
       214 
301 
     | 
    
         | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
            --------
         
     | 
| 
      
 302 
     | 
    
         
            +
            The fingerprint should be as shown above or you can independently verify it with the ones shown in the footer of https://mudge.name.
         
     | 
| 
       217 
303 
     | 
    
         | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
       219 
     | 
    
         
            -
              [`RE2::Regexp.new(re)`](https://github.com/google/re2/blob/2016-02-01/re2/re2.h#L100),
         
     | 
| 
       220 
     | 
    
         
            -
              `RE2::Regexp.compile(re)` or `RE2(re)` (including specifying options, e.g.
         
     | 
| 
       221 
     | 
    
         
            -
              `RE2::Regexp.new("pattern", :case_sensitive => false)`
         
     | 
| 
      
 304 
     | 
    
         
            +
            ### Installing the `ruby` platform gem
         
     | 
| 
       222 
305 
     | 
    
         | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
      
 306 
     | 
    
         
            +
            > [!WARNING]
         
     | 
| 
      
 307 
     | 
    
         
            +
            > We strongly recommend using the native gems where possible to avoid the need
         
     | 
| 
      
 308 
     | 
    
         
            +
            > for compiling the C++ extension and its dependencies which will take longer
         
     | 
| 
      
 309 
     | 
    
         
            +
            > and be less reliable.
         
     | 
| 
       225 
310 
     | 
    
         | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
      
 311 
     | 
    
         
            +
            If you wish to compile the gem, you will need to explicitly install the `ruby` platform gem:
         
     | 
| 
       227 
312 
     | 
    
         | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
             
     | 
| 
      
 313 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 314 
     | 
    
         
            +
            # In your Gemfile with Bundler 2.3.18+
         
     | 
| 
      
 315 
     | 
    
         
            +
            gem "re2", force_ruby_platform: true
         
     | 
| 
       230 
316 
     | 
    
         | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
      
 317 
     | 
    
         
            +
            # With Bundler 2.1+
         
     | 
| 
      
 318 
     | 
    
         
            +
            bundle config set force_ruby_platform true
         
     | 
| 
       232 
319 
     | 
    
         | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
      
 320 
     | 
    
         
            +
            # With older versions of Bundler
         
     | 
| 
      
 321 
     | 
    
         
            +
            bundle config force_ruby_platform true
         
     | 
| 
       234 
322 
     | 
    
         | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
      
 323 
     | 
    
         
            +
            # Without Bundler
         
     | 
| 
      
 324 
     | 
    
         
            +
            gem install re2 --platform=ruby
         
     | 
| 
      
 325 
     | 
    
         
            +
            ```
         
     | 
| 
       237 
326 
     | 
    
         | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
      
 327 
     | 
    
         
            +
            You will need a full compiler toolchain for compiling Ruby C extensions (see
         
     | 
| 
      
 328 
     | 
    
         
            +
            [Nokogiri's "The Compiler
         
     | 
| 
      
 329 
     | 
    
         
            +
            Toolchain"](https://nokogiri.org/tutorials/installing_nokogiri.html#appendix-a-the-compiler-toolchain))
         
     | 
| 
      
 330 
     | 
    
         
            +
            plus the toolchain required for compiling the vendored version of RE2 and its
         
     | 
| 
      
 331 
     | 
    
         
            +
            dependency [Abseil][] which includes
         
     | 
| 
      
 332 
     | 
    
         
            +
            [CMake](https://cmake.org) and a compiler with C++14 support such as
         
     | 
| 
      
 333 
     | 
    
         
            +
            [clang](http://clang.llvm.org/) 3.4 or [gcc](https://gcc.gnu.org/) 5. On
         
     | 
| 
      
 334 
     | 
    
         
            +
            Windows, you'll also need pkgconf 2.1.0+ to avoid [`undefined reference`
         
     | 
| 
      
 335 
     | 
    
         
            +
            errors](https://github.com/pkgconf/pkgconf/issues/322) when attempting to
         
     | 
| 
      
 336 
     | 
    
         
            +
            compile Abseil.
         
     | 
| 
       239 
337 
     | 
    
         | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
              with `re2.case_sensitive?`
         
     | 
| 
      
 338 
     | 
    
         
            +
            ### Using system libraries
         
     | 
| 
       242 
339 
     | 
    
         | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
       244 
     | 
    
         
            -
              original)`
         
     | 
| 
      
 340 
     | 
    
         
            +
            If you already have RE2 installed, you can instruct the gem not to use its own vendored version:
         
     | 
| 
       245 
341 
     | 
    
         | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
      
 342 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 343 
     | 
    
         
            +
            gem install re2 --platform=ruby -- --enable-system-libraries
         
     | 
| 
       248 
344 
     | 
    
         | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
      
 345 
     | 
    
         
            +
            # If RE2 is not installed in /usr/local, /usr, or /opt/homebrew:
         
     | 
| 
      
 346 
     | 
    
         
            +
            gem install re2 --platform=ruby -- --enable-system-libraries --with-re2-dir=/path/to/re2/prefix
         
     | 
| 
      
 347 
     | 
    
         
            +
            ```
         
     | 
| 
      
 348 
     | 
    
         
            +
             
     | 
| 
      
 349 
     | 
    
         
            +
            Alternatively, you can set the `RE2_USE_SYSTEM_LIBRARIES` environment variable instead of passing `--enable-system-libraries` to the `gem` command.
         
     | 
| 
       252 
350 
     | 
    
         | 
| 
       253 
     | 
    
         
            -
            * Pattern matching with `RE2::MatchData`
         
     | 
| 
       254 
351 
     | 
    
         | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
            -------------
         
     | 
| 
      
 352 
     | 
    
         
            +
            ## Thanks
         
     | 
| 
       257 
353 
     | 
    
         | 
| 
       258 
354 
     | 
    
         
             
            * Thanks to [Jason Woods](https://github.com/driskell) who contributed the
         
     | 
| 
       259 
355 
     | 
    
         
             
              original implementations of `RE2::MatchData#begin` and `RE2::MatchData#end`.
         
     | 
| 
         @@ -278,30 +374,21 @@ Contributions 
     | 
|
| 
       278 
374 
     | 
    
         
             
              switch to Ruby's `TypedData` API and the resulting garbage collection
         
     | 
| 
       279 
375 
     | 
    
         
             
              improvements in 2.4.0.
         
     | 
| 
       280 
376 
     | 
    
         | 
| 
       281 
     | 
    
         
            -
            Contact
         
     | 
| 
       282 
     | 
    
         
            -
            -------
         
     | 
| 
      
 377 
     | 
    
         
            +
            ## Contact
         
     | 
| 
       283 
378 
     | 
    
         | 
| 
       284 
379 
     | 
    
         
             
            All issues and suggestions should go to [GitHub Issues](https://github.com/mudge/re2/issues).
         
     | 
| 
       285 
380 
     | 
    
         | 
| 
       286 
     | 
    
         
            -
            License
         
     | 
| 
       287 
     | 
    
         
            -
            -------
         
     | 
| 
      
 381 
     | 
    
         
            +
            ## License
         
     | 
| 
       288 
382 
     | 
    
         | 
| 
       289 
383 
     | 
    
         
             
            This library is licensed under the BSD 3-Clause License, see `LICENSE.txt`.
         
     | 
| 
       290 
384 
     | 
    
         | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
       292 
     | 
    
         
            -
             
     | 
| 
      
 385 
     | 
    
         
            +
            Copyright © 2010, Paul Mucur.
         
     | 
| 
      
 386 
     | 
    
         
            +
             
     | 
| 
      
 387 
     | 
    
         
            +
            ### Dependencies
         
     | 
| 
       293 
388 
     | 
    
         | 
| 
       294 
389 
     | 
    
         
             
            The 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`.
         
     | 
| 
       295 
390 
     | 
    
         | 
| 
       296 
391 
     | 
    
         
             
            The 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`.
         
     | 
| 
       297 
392 
     | 
    
         | 
| 
       298 
393 
     | 
    
         
             
              [RE2]: https://github.com/google/re2
         
     | 
| 
       299 
     | 
    
         
            -
              [gcc]: http://gcc.gnu.org/
         
     | 
| 
       300 
     | 
    
         
            -
              [ruby-dev]: http://packages.debian.org/ruby-dev
         
     | 
| 
       301 
     | 
    
         
            -
              [build-essential]: http://packages.debian.org/build-essential
         
     | 
| 
       302 
     | 
    
         
            -
              [Regexp]: http://ruby-doc.org/core/classes/Regexp.html
         
     | 
| 
       303 
     | 
    
         
            -
              [MatchData]: http://ruby-doc.org/core/classes/MatchData.html
         
     | 
| 
       304 
     | 
    
         
            -
              [Homebrew]: http://mxcl.github.com/homebrew
         
     | 
| 
       305 
     | 
    
         
            -
              [libre2-dev]: http://packages.debian.org/search?keywords=libre2-dev
         
     | 
| 
       306 
     | 
    
         
            -
              [official syntax page]: https://github.com/google/re2/wiki/Syntax
         
     | 
| 
       307 
394 
     | 
    
         
             
              [Abseil]: https://abseil.io
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -33,7 +33,7 @@ Gem::PackageTask.new(RE2_GEM_SPEC) do |p| 
     | 
|
| 
       33 
33 
     | 
    
         
             
              p.need_tar = false
         
     | 
| 
       34 
34 
     | 
    
         
             
            end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
            CROSS_RUBY_VERSIONS = %w[3.2.0 3.1.0 3.0.0 2.7.0 2.6.0].join(':')
         
     | 
| 
      
 36 
     | 
    
         
            +
            CROSS_RUBY_VERSIONS = %w[3.3.0 3.2.0 3.1.0 3.0.0 2.7.0 2.6.0].join(':')
         
     | 
| 
       37 
37 
     | 
    
         
             
            CROSS_RUBY_PLATFORMS = %w[
         
     | 
| 
       38 
38 
     | 
    
         
             
              aarch64-linux
         
     | 
| 
       39 
39 
     | 
    
         
             
              arm-linux
         
     |