# Ruby 2.1 regexes equivalent to Perl 5.18?

**URL:** <https://www.ruby-forum.com/t/ruby-2-1-regexes-equivalent-to-perl-5-18/231208>\
**Category:** Ruby\
**Created:** [July 27, 2014, 3:40pm UTC](https://www.ruby-forum.com/t/ruby-2-1-regexes-equivalent-to-perl-5-18/231208 "2014-07-27T15:40:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 27, 2014, 3:40pm UTC](https://www.ruby-forum.com/t/ruby-2-1-regexes-equivalent-to-perl-5-18/231208/1 "2014-07-27T15:40:05Z")

</div>

Are Ruby regexes in 2.1 equivalent in power to those in Perl 5.18?

gvim

---

<div class="post-metadata">

**Author:** ![gvim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a3d4f5/32.png) [@gvim](https://www.ruby-forum.com/u/gvim)\
**Post date:** [July 27, 2014, 6:44pm UTC](https://www.ruby-forum.com/t/ruby-2-1-regexes-equivalent-to-perl-5-18/231208/2 "2014-07-27T18:44:20Z")

</div>

Did you run a diff and benchmark them? Sort of strange one line  
question. I  
doubt you’ll get a real world response. For the end user that is  
effective  
with regexes (old school UNIX on every platform systems programmer) the  
answer would be yes. For the rest of them let them eat cake since the  
cake  
is a lie!

---

<div class="post-metadata">

**Author:** ![gvim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a3d4f5/32.png) [@gvim](https://www.ruby-forum.com/u/gvim)\
**Post date:** [July 28, 2014, 2:26am UTC](https://www.ruby-forum.com/t/ruby-2-1-regexes-equivalent-to-perl-5-18/231208/3 "2014-07-28T02:26:08Z")

</div>

On 27/07/2014 17:43, Stu wrote:

> Did you run a diff and benchmark them? Sort of strange one line  
> question. I doubt you’ll get a real world response. For the end user  
> that is effective with regexes (old school UNIX on every platform  
> systems programmer) the answer would be yes. For the rest of them let  
> them eat cake since the cake is a lie!

I was thinking more in terms of features rather than performance. Last I  
checked the Onigma regex engine was Perl 5.10 compatible but wondered if  
anything has changed since then.

gvim

---

<div class="post-metadata">

**Author:** ![gvim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a3d4f5/32.png) [@gvim](https://www.ruby-forum.com/u/gvim)\
**Post date:** [August 1, 2014, 12:16pm UTC](https://www.ruby-forum.com/t/ruby-2-1-regexes-equivalent-to-perl-5-18/231208/4 "2014-08-01T12:16:13Z")

</div>

On Mon, Jul 28, 2014 at 2:25 AM, gvim [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I was thinking more in terms of features rather than performance. Last I  
> checked the Onigma regex engine was Perl 5.10 compatible but wondered if  
> anything has changed since then.

That cannot be. There is at least one feature in Perl Regex which  
does not exist in Ruby: command execution inside the regex engine.  
Not that I think it is a good feature to have as it can make the whole  
matching process very hard to understand but at least there is no  
strict feature equality. But since 1.9 Ruby has lookaround, various  
levels of greediness and can even made to match recursive structures  
like nested brackets (this extends the class of languages which can be  
recognized beyond pure regular languages btw.) - all things that the  
Perl RE also features.

I’d go with Stu: for all practical matters since 1.9 (i.e. Oniguruma)  
there is nothing I am missing. For a brief overview you can look  
here:  
[http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt](http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt)

Btw. since Ruby 2.0 the regex engine is called “Onigmo”:

> **[Ruby 2.0.0-p0 is released | Ruby](https://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/)**
>
> We are pleased to announce the release of Ruby 2.0.0-p0.

Kind regards

robert
