Help for this page

Select Code to Download


  1. or download this
    # Matches strings that include "ab" or "cd"
    /ab|cd/
    
    # Matches strings that include "abd" or "acd".
    /a(?:b|c)d/
    
  2. or download this
    local $_ = 'foo bar bar baz';
    my $term = 'bar';
    ...
    my $num_matches = () = /(?:\W|^)\Q$term\E(?:(?=\W)|\z)/g;
    print("$num_matches\n");
    # 2: foo[ bar][ bar] baz