Skip to content

Releases: mudge/re2

2.0.0: vendored RE2 2023-09-01 & native gems

13 Sep 18:11
Compare
Choose a tag to compare

This is a major new version of re2 which no longer requires the RE2 library to be installed as the latest version (2023-09-01) is now vendored with the gem.

Vendored RE2

Installing the gem will also compile and install RE2 (and its dependency, Abseil). As this can take some time, precompiled native gems are available for the following platforms meaning there’s no need to wait for compilation in the majority of cases:

  • aarch64-linux (requires: glibc >= 2.29)
  • arm-linux (requires: glibc >= 2.29)
  • arm64-darwin
  • x64-mingw32 / x64-mingw-ucrt
  • x86-linux (requires: glibc >= 2.17)
  • x86_64-darwin
  • x86_64-linux (requires: glibc >= 2.17)

Breaking changes

Due to a new dependency on MiniPortile2 and the need to include compiled C extensions for every supported version of Ruby in the native gems, this major version drops support for all Ruby versions prior to 2.6.

Opting out of the vendored RE2

To opt out of using the gem’s vendored dependencies and instead rely on the previous behaviour of linking against a system install of RE2, use the --enable-system-libraries option when installing the gem.

Note you’ll also need to use the ruby platform to avoid the native gems either via gem install re2 --platform=ruby -- --enable-system-libraries or Bundler's force_ruby_platform option.

Thanks

This major release would not have happened without @stanhu.


SHA256 checksums:

677ddce4c38d659de899651acbfd7c6b5331f984a7101d9179ac247284f2212a  re2-2.0.0-aarch64-linux.gem
f657d689922e5ac215b486e4f2ca909f1079eab616269a1d8fc0cccd63ef28af  re2-2.0.0-arm-linux.gem
ffc8e5663381ff344ee6a2e55c7d0be81ef9b43174a41e977c4e18a11f965be1  re2-2.0.0-arm64-darwin.gem
253b3de21ca563cdb93c9fd69738a2a66713e381bae4530ff2cae105c6fd1a8e  re2-2.0.0-x64-mingw-ucrt.gem
d4b52fc21719f262c2a438912f009da868b31aed1688ec90e4e1696898fb53d3  re2-2.0.0-x64-mingw32.gem
26abee219e3fd69ba5c6a7bdb882880b8af6502cf912da7a7837e38ad02a29e7  re2-2.0.0-x86-linux.gem
ffec6da4c547e44a6c1a467b0b01b2dcc2940e081923221a2ac3e4b08a219c26  re2-2.0.0-x86-mingw32.gem
48b3ba3fea8cc84709a4195300cd1c627b2496f16e5865662c54e67f7aca1ccf  re2-2.0.0-x86_64-darwin.gem
1fb161e6e5d9efed59ed0062536f2cb9ab5fba367e209d0dc66f99f2864d42ff  re2-2.0.0-x86_64-linux.gem
09075fab88b7ab40c2374d75a20504408dc26539c11931b146d5f72892718925  re2-2.0.0.gem

2.0.0.beta2: RE2 2023-09-01, fix for compiling against system RE2 & Ruby 2.6 support

10 Sep 17:10
a3c7531
Compare
Choose a tag to compare

Please install this release with gem install re2 --pre and report any issues you find.

Fixes since beta1

  • Upgraded the vendored RE2 to the latest version: 2023-09-01.
  • @stanhu fixed a problem when opting out of the precompiled, native gems and compiling the gem against a system RE2 that also happens to be Ruby’s default exec_prefix directory.
  • We’ve restored support for Ruby 2.6 and that is now included in the native gems meaning the gem can be installed against the default system Ruby on macOS Monterey.

2.0.0.beta1: vendor RE2, native gems

07 Sep 19:44
3185cbd
Compare
Choose a tag to compare
Pre-release

Thanks to @stanhu: this is the first beta release of a major new version of re2 which no longer requires the RE2 library to be installed as it is now vendored with the gem (ala Nokogiri and libxml2).

Installing the gem will also compile and install RE2 (and its dependency, abseil). As this can take some time, precompiled native gems are available for major platforms meaning there’s no need to wait for compilation.

Due to a new dependency on MiniPortile2 and the need to include compiled C extensions for every supported version of Ruby in the native gems, this major version drops support for all Ruby versions prior to 2.7, matching Nokogiri’s policy of supporting the last 4 minor versions of Ruby (2.7, 3.0, 3.1 and 3.2).

To opt out of using the gem’s vendored dependencies and instead rely on the previous behaviour of linking against a system install of RE2, use the --enable-system-libraries option when installing the gem (note you’ll need to use the ruby platform to avoid the native gems too).

Known issues

  • Installing and compiling the ruby platform gem (i.e. not one of the precompiled native gems) with the bundled dependencies on a system which has its own RE2 library installed in Ruby’s default exec_path will link incorrectly, see #93

1.7.0: re2 2023-07-01 support

04 Jul 19:56
26d7be0
Compare
Choose a tag to compare

Thanks to @stanhu for adding support for the latest version of re2—2023-07-01—which now depends on Abseil and therefore requires a compiler with C++14 support or newer.

1.6.0: Pattern matching RE2::MatchData

22 Oct 07:38
8bb59cf
Compare
Choose a tag to compare

In order to support pattern matching in recent versions of Ruby, implement RE2::MatchData#deconstruct and RE2::MatchData#deconstruct_keys. This allows matches to be matched with both array and hash patterns, e.g.

case RE2('(\w+) (\d+)').match("Alice 42")
in [name, age]
  puts "My name is #{name} and I am #{age} years old"
else
  puts "No match!"
end
# My name is Alice and I am 42 years old

case RE2('(?P<name>\w+) (?P<age>\d+)').match("Alice 42")
in {name:, age:}
  puts "My name is #{name} and I am #{age} years old"
else
  puts "No match!"
end
# My name is Alice and I am 42 years old

This is inspired by ruby/ruby#6216. Thanks to @tomstuart for drawing my attention to it.

1.5.0: Add RE2::Set for searching a collection of patterns simultaneously

16 Oct 19:09
75951ac
Compare
Choose a tag to compare

Contributed by @pritambaral, add RE2::Set representing a collection of patterns that can be searched for simultaneously.

Patterns are added to a set with RE2::Set#add—returning the index of the pattern in the set—and then compiled with RE2::Set#compile. Calling RE2::Set#match with text will return an array of integer indices of matching patterns, e.g.

set = RE2::Set.new
set.add("abc") #=> 0
set.add("def") #=> 1
set.add("ghi") #=> 2
set.compile #=> true
set.match("abcdefghi") #=> [0, 1, 2]
set.match("ghidefabc") #=> [2, 1, 0]

Depending on the ABI version of the underlying re2 library, RE2::Set#match will raise exceptions if there are any errors when matching. For ABI version 0, no error information is output so RE2::Set#match can be passed an :exception option of false to silently return an empty array if there are any errors, e.g.

set = RE2::Set.new
set.match("abcdef", exception: false) #=> []

1.4.0: Fix crash when using RE2::Scanner#scan with an invalid regular expression

29 Mar 12:28
7415e55
Compare
Choose a tag to compare

As reported by @serch in #52, fix a crash when using RE2::Scanner#scan with an invalid regular expression.

This was caused by the underlying re2 library returning -1 as the number of capturing groups for an invalid regular expression and using that value to initialize memory when incrementally scanning with RE2::Scanner. We now explicitly check an expression is valid and return nil if it isn't.

> pattern = RE2::Regexp.new('???')
/tmp/re2-20210214-21445-1a81zn5/re2-2021-02-02/re2/re2.cc:205: Error parsing '???': no argument for repetition operator: ??
=> #<RE2::Regexp /???/>
> scanner = pattern.scan('Some text')
=> #<RE2::Scanner:0x00007f951d981840>
> scanner.scan
/tmp/re2-20210214-21445-1a81zn5/re2-2021-02-02/re2/re2.cc:890: Invalid RE2: no argument for repetition operator: ??
=> nil
> scanner.to_a
/tmp/re2-20210214-21445-1a81zn5/re2-2021-02-02/re2/re2.cc:890: Invalid RE2: no argument for repetition operator: ??
=> []

This also fixes an edge case when using RE2::Regexp#match and specifying a negative number of matches which would previously raise a NoMemoryError but will now raise a more informative ArgumentError:

> RE2::Regexp.new('(\d+)').match('1 2 3', -1)
ArgumentError: number of matches should be >= 0
from (pry):5:in `match'

1.3.0: Support Homebrew on Apple Silicon by default

12 Mar 13:43
372b6df
Compare
Choose a tag to compare

GitHub: #50

To make installation easier for users of Homebrew on Apple Silicon, add /opt/homebrew to the default paths searched when trying to find the underlying re2 library. While doing so, add an extra fallback to /usr (instead of only searching /usr/local).

Note we still search /usr/local first to avoid accidentally changing behaviour for existing users (e.g. suddenly compiling against a different version of re2 in /usr).

1.2.0: Stop using deprecated re2 APIs

18 Apr 11:08
Compare
Choose a tag to compare

GitHub: #40

As re2 has deprecated and now removed the utf8 option, re-implement the option in the gem in terms of the encoding and set_encoding API.

This should be entirely backward-compatible as the encoding API has been present since the initial release in 2010.

Thanks to @buzzdeee for reporting this upcoming breaking change.

1.0.0: One Point Oh

14 Nov 22:21
Compare
Choose a tag to compare

After being used in production at @altmetric for a while now and having been six years since its first release, it's time for re2 1.0.0.

The only notable change from 0.7.0 is support for recent versions of the underlying re2 library which require C++11 support.

The gem still supports older versions of re2 but any attempt to compile newer versions will require a compiler with appropriate language support (e.g. clang 3.4 on Ubuntu 12.04).