@@ -4,7 +4,7 @@ re2 [, 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)
10
10
@@ -131,6 +131,22 @@ enum.next #=> ["It"]
131
131
enum.next # => ["is"]
132
132
```
133
133
134
+ As of 1.5.0, you can use ` RE2::Set ` to match multiple patterns against a
135
+ string. Calling ` RE2::Set#add ` with a pattern will return an integer index of
136
+ the pattern. After all patterns have been added, the set can be compiled using
137
+ ` RE2::Set#compile ` , and then ` RE2::Set#match ` will return an ` Array<Integer> `
138
+ containing the indices of all the patterns that matched.
139
+
140
+ ``` ruby
141
+ set = RE2 ::Set .new
142
+ set.add(" abc" ) # => 0
143
+ set.add(" def" ) # => 1
144
+ set.add(" ghi" ) # => 2
145
+ set.compile # => true
146
+ set.match(" abcdefghi" ) # => [0, 1, 2]
147
+ set.match(" ghidefabc" ) # => [2, 1, 0]
148
+ ```
149
+
134
150
Features
135
151
--------
136
152
@@ -149,6 +165,8 @@ Features
149
165
150
166
* Incrementally scanning text with ` re2.scan(text) `
151
167
168
+ * Search a collection of patterns simultaneously with ` RE2::Set `
169
+
152
170
* Checking regular expression compilation with ` re2.ok? ` , ` re2.error ` and
153
171
` re2.error_arg `
154
172
@@ -177,7 +195,9 @@ Contributions
177
195
* Thanks to [ Sebastian Reitenbach] ( https://github.com/buzzdeee ) for reporting
178
196
the deprecation and removal of the ` utf8 ` encoding option in re2;
179
197
* Thanks to [ Sergio Medina] ( https://github.com/serch ) for reporting a bug when
180
- using ` RE2::Scanner#scan ` with an invalid regular expression.
198
+ using ` RE2::Scanner#scan ` with an invalid regular expression;
199
+ * Thanks to [ Pritam Baral] ( https://github.com/pritambaral ) for contributed the
200
+ initial support for ` RE2::Set ` .
181
201
182
202
Contact
183
203
-------
0 commit comments