Help for this page

Select Code to Download


  1. or download this
    $_ = "it's 94% fat-free!";    # a string that should match
    
    # the following code works but the logic is outside the RE
    ...
    
    # the following code also works but is offensive
    print "match\n" if /(\d{1,3})%(?(?{$1>91})(?:.*)|(?!.*))/;
    
  2. or download this
    /(\d{1,3})%  # find a percentage to match
    (?(         # begin conditional construct
    ?{$1>91})   # return value of a code block can be used to test
    (?:.*)    # RE to use if true -- this always-true RE makes entire RE m
    +atch
    |
    (?!.*))/  # RE to use if false -- this always-false RE makes entire RE
    + fail