Project

General

Profile

Bug #5624 ยป 0001-Update-code-example-to-match-its-description-in-text.patch

jlamberg (Jarno Lamberg), 11/13/2011 08:02 AM

View differences:

doc/re.rdoc
533 533
Consider a string of 25 <i>a</i>s, a <i>d</i>, 4 <i>a</i>s, and a
534 534
<i>c</i>.
535 535

  
536
    s = 'a' * 25 + 'd' 'a' * 4 + 'c'
537
        #=> "aaaaaaaaaaaaaaaaaaaaaaaaadadadadac"
536
    s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
537
        #=> "aaaaaaaaaaaaaaaaaaaaaaaaadaaaac"
538 538

  
539 539
The following patterns match instantly as you would expect:
540 540

  
......
544 544

  
545 545
However, the following pattern takes appreciably longer:
546 546

  
547
    /(b|a+)*c/ =~ s #=> 32
547
    /(b|a+)*c/ =~ s #=> 26
548 548

  
549 549
This happens because an atom in the regexp is quantified by both an
550 550
immediate <tt>+</tt> and an enclosing <tt>*</tt> with nothing to