A couple of questions from a Ruby neophyte

  • Thread starter planetthoughtful
  • Start date
P

Phrogz

On 8 mar, 09:08, "planetthoughtful" <[email protected]>
As you asked in the Ruby list, and Perl/Python/Ruby were mentioned,
I'll give you answers for them.

An excellent, informative post. Thanks for sharing!

One question:
Ruby1.8's regexp engine is less powerful than Perl's or Python's as it
does not have backtracking, named groups or unicode (if you don't know
what that is or care, ruby1.8's regexp are perfect for you already).

If I understand the terminology correctly, the 1.8 regexp engine
doesn't support lookbehind assertions (positive or negative), but it
does support backtracking. Isn't backtracking what permits /.*bar/ to
match "foobar"? Without backtracking, .* would match "foobar", and
then the regexp would fail when it didn't find another "bar" after
"foobar".
 
R

Robert Klemme

If I understand the terminology correctly, the 1.8 regexp engine
doesn't support lookbehind assertions (positive or negative), but it
does support backtracking. Isn't backtracking what permits /.*bar/ to
match "foobar"? Without backtracking, .* would match "foobar", and
then the regexp would fail when it didn't find another "bar" after
"foobar".

Yes. Basically NFA regexp engines have to do backtracking, DFA's don't.
See "Mastering Regular Expressions" for details.

Kind regards

robert
 

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,777
Messages
2,569,604
Members
45,222
Latest member
patricajohnson51

Latest Threads

Top