Help for this page

Select Code to Download


  1. or download this
    my $count =()= 'abracadabra' =~ /br/g;
    print "Found $count instances\n"
    # prints Found 2 instances
    
  2. or download this
    sub countOverlappingMatches
    {
      my $stringRef = shift;  #Likely to be huge, don't make a copy
    ...
    }
    
    print countOverlappingMatches(\'abrabrabrabra', \'rabra');  # 3
    
  3. or download this
    for my $pattern (@listOfPatterns)
    {
      my $count =()= $string =~ /(?=$pattern)/g;
      # Play with $count
    }