Help for this page

Select Code to Download


  1. or download this
    # capture all two\d that are not preceded by fo+
    $_ = 'footwo1 bootwo2 ftwo3 fotwo4';
    $not = qr/fo+/;
    $want = qr/two\d/;
    print "Got $1\n" while /\G(?:(?!$not?$want).|$not$want)*($want)/g;
    
  2. or download this
    s/\G((?:(?!$not?$want).|$not$want)*)($want)/$1X/g;
    
  3. or download this
    s/\G$want/X/ while /\G(?:(?!$not?$want).|$not$want)*(?=$want)/g;
    
  4. or download this
    s/\G((?:(?!$not?$want).|$not$want)*)\K($want)/X/g;
    # yielded
    Eval-group not allowed at runtime, use re 'eval' in regex m/\G((?:(?!(
    +?-xism:fo+)?(?-xism:two\d)).|(?-xism:fo+)(?-xism:two\d))*)(?{Regexp::
    +Keep::KEEP})((?-xism:two\d))/ at try2.pl line 9.