Help for this page

Select Code to Download


  1. or download this
        my $pat = qr/\w+ ((w)hite|(b)lack)/;
    
    ...
    
        $_ = 'but some white spaces';
        print "$1 starts with $+\n" if /$pat/;
    
  2. or download this
        my $pat = qr/\w+ ((w)hit(e)|(b)lac(k))/;
    
    ...
        $_ = 'but some white spaces';
        ($word, $first, $last) = grep defined $_, /$pat/;
        print "$word starts with $first and ends with $last\n" if $word;
    
  3. or download this
        my $pat = qr/\w+ ((w)hit(e)|(b)lac(k))/;
        $str = 'mostly black but some white spaces';
    ...
                    :()
                } 0..$#+;
        }