# Compatibility in regexps between perl and ruby

**URL:** <https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131>\
**Category:** Ruby\
**Created:** [September 8, 2007, 10:50am UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131 "2007-09-08T10:50:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tammo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@Tammo\_T](https://www.ruby-forum.com/u/Tammo_T)\
**Post date:** [September 8, 2007, 10:50am UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131/1 "2007-09-08T10:50:37Z")

</div>

Hello,  
I try to translate some perl to ruby and assumed so far that the regexps  
are  
compatible. But it seems that there are some only available in perl.  
Is there something comparable to  
(?\<!..)  
also in ruby (is a zerowidth lookbehind, so  
/(?\<!test)moin/ would only match moin if no test preceeds.

Regards,  
Tammo

---

<div class="post-metadata">

**Author:** ![Tammo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@Tammo\_T](https://www.ruby-forum.com/u/Tammo_T)\
**Post date:** [September 8, 2007, 11:25am UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131/2 "2007-09-08T11:25:40Z")

</div>

Hi,

You are right: the zerowidth lookbehind isn’t still implemented in  
Ruby 1.8. We have to wait for the new engine “oniguruma”, and the 1.9  
version.

You can install oniguruma as a gem in Ruby 1.8.

Come

---

<div class="post-metadata">

**Author:** ![Tammo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@Tammo\_T](https://www.ruby-forum.com/u/Tammo_T)\
**Post date:** [September 8, 2007, 11:40am UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131/3 "2007-09-08T11:40:43Z")

</div>

Hi,

thanks for the quick answer, does “oniguruma” support all regexps of  
perl?  
I stumbled over another one, where ?(…) is used, where … is some check  
( a  
number). It referes to the revious matches and matches the following  
expression only if the expression in the by … given has matched.  
E.g.  
/(foo) (() (+) ?(2) ())/  
matches the closing ) only if a opening occured (referes to the matching  
in  
the second (…)

Best regards,  
Tammo

---

<div class="post-metadata">

**Author:** ![Tammo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@Tammo\_T](https://www.ruby-forum.com/u/Tammo_T)\
**Post date:** [September 9, 2007, 12:22am UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131/4 "2007-09-09T00:22:08Z")

</div>

Will it be default in the next version?

---

<div class="post-metadata">

**Author:** ![Tammo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@Tammo\_T](https://www.ruby-forum.com/u/Tammo_T)\
**Post date:** [September 9, 2007, 3:04am UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131/5 "2007-09-09T03:04:15Z")

</div>

On 9/8/07, Bernardo Monteiro R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Will it be default in the next version?

Oniguruma is the default engine in Ruby 1.9, and presumably for  
subsequent versions as well.

---

<div class="post-metadata">

**Author:** ![Tammo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@Tammo\_T](https://www.ruby-forum.com/u/Tammo_T)\
**Post date:** [September 8, 2007, 11:01pm UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131/6 "2007-09-08T23:01:00Z")

</div>

Tammo T. wrote:

> 

> **[Ruby | zenspider.com | by ryan davis](https://www.zenspider.com/ruby/)**
>
> Ruby facts, opinions, source code, links, and stuff.

---

<div class="post-metadata">

**Author:** ![Tammo\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@Tammo\_T](https://www.ruby-forum.com/u/Tammo_T)\
**Post date:** [September 9, 2007, 10:29am UTC](https://www.ruby-forum.com/t/compatibility-in-regexps-between-perl-and-ruby/114131/7 "2007-09-09T10:29:55Z")

</div>

Tammo T. wrote:

> Hi,
> 
> thanks for the quick answer, does “oniguruma” support all regexps of  
> perl?

It does not support the experimental features like using code inside a  
regular expression.  
The Oniguruma features are described in

[http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt](http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt)

Wolfgang NÃ¡dasi-Donner
