Help for this page

Select Code to Download


  1. or download this
    $regex = join ...
    $regex = qr/...
    
  2. or download this
    $regex_base_str = join ...
    $regex_compiled = qr/...
    
  3. or download this
    # Simple case: OK - matches "a" or "b"
    $ perl -E 'my $re = "a|b"; $re = qr{$re}; say $re'
    ...
    # Complex case: OK - matches "a" or "b" [fixed with "(?:...)"]
    $ perl -E 'my $re = "(?:a|b)"; $re = qr{X${re}Y}; say $re'
    (?^u:X(?:a|b)Y)