re2 2.4.3-aarch64-linux → 2.6.0-aarch64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31bc284bb7f3f24ad0fe291ece346eafb484863ecf0f30d4ec799ba844e059ad
4
- data.tar.gz: 29199e8a8d0c2165d17ecce3c39343d5228e3bd817616dc7cd576abbc454b1f5
3
+ metadata.gz: c8f6ef06ddd556c408e9b6b44f4c936d8247707d39d879069f737aa4d03298f4
4
+ data.tar.gz: 14d7c359edab262e41cc80b6f9dd83a3c3ec5fe9baa62dceb864f182b7a8af58
5
5
  SHA512:
6
- metadata.gz: 3e02625f399fda1f48e34f8d34c6d17319c520e515123a6044e739a2146c3ddd42caa93478fae1750291c6a57f35b701d4b6edb71383be72f0dc44c00deb8595
7
- data.tar.gz: 4700f794748edb1f1062eccfad6b05f5e6bfbb728449a1d34b4c0a5c4a7b90c11b9c47db3b7b67bbc339c0f9e552a8ef9447eed6fdd3a19ec7efe3e561bccb45
6
+ metadata.gz: 2e1d11367a71ce0cb3ca44e73601a6eaa7545f5f1498dda5d164fb10a22f4a7e53da9206e557f0215856b2447df91c67befde0e84b4a6956e6992274a2b134d6
7
+ data.tar.gz: 56cd4a0af9a14d1bd863177cf8d4e53ceee385a381d8eb174d672bb8c1ba975ca12d7155661966d473aea629d5fffae0984656b192e91887e1655ccc5cf8b589
data/README.md CHANGED
@@ -1,205 +1,246 @@
1
- re2 [![Build Status](https://github.com/mudge/re2/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mudge/re2/actions)
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
- **Current version:** 2.4.3
9
- **Supported Ruby versions:** 2.6, 2.7, 3.0, 3.1, 3.2
7
+ [![Build Status](https://github.com/mudge/re2/actions/workflows/tests.yml/badge.svg?branch=main)](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
- Installation
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
- The gem comes bundled with a version of [RE2][] and will compile itself (and
17
- any dependencies) on install. As compilation can take a while, precompiled
18
- native gems are available for Linux, Windows and macOS.
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
- In v2.0 and later, precompiled native gems are available for Ruby 2.6 to 3.2
21
- on these platforms:
68
+ ```ruby
69
+ # In your Gemfile
70
+ gem "re2"
22
71
 
23
- - `aarch64-linux` (requires: glibc >= 2.29)
24
- - `arm-linux` (requires: glibc >= 2.29)
25
- - `arm64-darwin`
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
- If you wish to opt out of using the bundled libraries, you will need RE2
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
- $ brew install re2
78
+ ```ruby
79
+ require "re2"
80
+ ```
37
81
 
38
- If you are using Debian, you can install the [libre2-dev][] package like so:
82
+ Full API documentation automatically generated from the latest version is
83
+ available at https://mudge.name/re2/.
39
84
 
40
- $ sudo apt-get install libre2-dev
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
- Recent versions of RE2 require [CMake](https://cmake.org) and a compiler with
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
- If you are using a packaged Ruby distribution, make sure you also have the
47
- Ruby header files installed such as those provided by the [ruby-dev][] package
48
- on Debian and Ubuntu.
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
- You can then install the library via RubyGems with `gem install re2 --platform=ruby --
51
- --enable-system-libraries` or `gem install re2 --platform=ruby -- --enable-system-libraries
52
- --with-re2-dir=/path/to/re2/prefix` if RE2 is not installed in any of the
53
- following default locations:
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
- * `/usr/local`
56
- * `/opt/homebrew`
57
- * `/usr`
103
+ ```ruby
104
+ re = RE2('(\w+):(\d+)')
105
+ #=> #<RE2::Regexp /(\w+):(\d+)/>
106
+ re.ok? #=> true
58
107
 
59
- Alternatively, you can set the `RE2_USE_SYSTEM_LIBRARIES` environment variable instead of passing `--enable-system-libraries` to the `gem` command.
108
+ re = RE2('abc)def')
109
+ re.ok? #=> false
110
+ re.error #=> "missing ): abc(def"
111
+ ```
60
112
 
61
- If you're using Bundler, you can use the
62
- [`force_ruby_platform`](https://bundler.io/v2.3/man/gemfile.5.html#FORCE_RUBY_PLATFORM)
63
- option in your Gemfile.
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
- Documentation
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
- Full documentation automatically generated from the latest version is
69
- available at <http://mudge.name/re2/>.
119
+ ```ruby
120
+ RE2('abc)def', log_errors: false)
121
+ ```
70
122
 
71
- Note that RE2's regular expression syntax differs from PCRE and Ruby's
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
- Usage
76
- -----
125
+ ### Matching interface
77
126
 
78
- While re2 uses the same naming scheme as Ruby's built-in regular expression
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
- ```console
84
- $ irb -rubygems
85
- > require 're2'
86
- > r = RE2::Regexp.new('w(\d)(\d+)')
87
- => #<RE2::Regexp /w(\d)(\d+)/>
88
- > m = r.match("w1234")
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
- As
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
- ```console
113
- > RE2('(\d+)')
114
- => #<RE2::Regexp /(\d+)/>
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
- Note the use of *single quotes* as double quotes will interpret `\d` as `d` as
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
- ```console
121
- > RE2("(\d+)")
122
- => #<RE2::Regexp /(d+)/>
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
- As of 0.3.0, you can use named groups:
158
+ `RE2::MatchData` supports retrieving submatches by numeric index or by name if present in the regular expression:
126
159
 
127
- ```console
128
- > r = RE2::Regexp.new('(?P<name>\w+) (?P<age>\d+)')
129
- => #<RE2::Regexp /(?P<name>\w+) (?P<age>\d+)/>
130
- > m = r.match("Bob 40")
131
- => #<RE2::MatchData "Bob 40" 1:"Bob" 2:"40">
132
- > m[:name]
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
- As of 0.6.0, you can use `RE2::Regexp#scan` to incrementally scan text for
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
- re = RE2('(\w+)')
148
- scanner = re.scan("It is a truth universally acknowledged")
149
- scanner.each do |match|
150
- puts match
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
- scanner.rewind
154
-
155
- enum = scanner.to_enum
156
- enum.next #=> ["It"]
157
- enum.next #=> ["is"]
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
- As of 1.5.0, you can use `RE2::Set` to match multiple patterns against a
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
- set = RE2::Set.new
168
- set.add("abc") #=> 0
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
- As of 1.6.0, you can use [Ruby's pattern matching](https://docs.ruby-lang.org/en/3.0/syntax/pattern_matching_rdoc.html) against `RE2::MatchData` with both array patterns and hash patterns:
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
- case RE2('(\w+) (\d+)').match("Alice 42")
180
- in [name, age]
181
- puts "My name is #{name} and I am #{age} years old"
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
- # My name is Alice and I am 42 years old
210
+ # ["one"]
211
+ # ["two"]
212
+ # ["three"]
213
+ # ["4"]
214
+ ```
186
215
 
216
+ ### Searching simultaneously
187
217
 
188
- case RE2('(?P<name>\w+) (?P<age>\d+)').match("Alice 42")
189
- in {name:, age:}
190
- puts "My name is #{name} and I am #{age} years old"
191
- else
192
- puts "No match!"
193
- end
194
- # My name is Alice and I am 42 years old
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
- Note RE2 only supports UTF-8 and ISO-8859-1 encoding so strings will be
201
- returned in UTF-8 by default or ISO-8859-1 if the `:utf8` option for the
202
- `RE2::Regexp` is set to false (any other encoding's behaviour is undefined).
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"), :utf8 => false).match(non_latin1_text.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
- Features
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
- * Pre-compiling regular expressions with
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
- * Extracting matches with `re2.match(text)` (and an exact number of matches
224
- with `re2.match(text, number_of_matches)` such as `re2.match("123-234", 2)`)
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
- * Extracting matches by name (both with strings and symbols)
311
+ If you wish to compile the gem, you will need to explicitly install the `ruby` platform gem:
227
312
 
228
- * Checking for matches with `re2 =~ text`, `re2 === text` (for use in `case`
229
- statements) and `re2 !~ text`
313
+ ```ruby
314
+ # In your Gemfile with Bundler 2.3.18+
315
+ gem "re2", force_ruby_platform: true
230
316
 
231
- * Incrementally scanning text with `re2.scan(text)`
317
+ # With Bundler 2.1+
318
+ bundle config set force_ruby_platform true
232
319
 
233
- * Search a collection of patterns simultaneously with `RE2::Set`
320
+ # With older versions of Bundler
321
+ bundle config force_ruby_platform true
234
322
 
235
- * Checking regular expression compilation with `re2.ok?`, `re2.error` and
236
- `re2.error_arg`
323
+ # Without Bundler
324
+ gem install re2 --platform=ruby
325
+ ```
237
326
 
238
- * Checking regular expression "cost" with `re2.program_size`
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
- * Checking the options for an expression with `re2.options` or individually
241
- with `re2.case_sensitive?`
338
+ ### Using system libraries
242
339
 
243
- * Performing a single string replacement with `pattern.replace(replacement,
244
- original)`
340
+ If you already have RE2 installed, you can instruct the gem not to use its own vendored version:
245
341
 
246
- * Performing a global string replacement with
247
- `pattern.replace_all(replacement, original)`
342
+ ```ruby
343
+ gem install re2 --platform=ruby -- --enable-system-libraries
248
344
 
249
- * Escaping regular expressions with
250
- [`RE2.escape(unquoted)`](https://github.com/google/re2/blob/2016-02-01/re2/re2.h#L418) and
251
- `RE2.quote(unquoted)`
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
- Contributions
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
- Dependencies
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