compatibility in regexps between perl and ruby

T

Tammo Tjarks

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
 
C

come

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
 
T

Tammo Tjarks

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top