Help for this page

Select Code to Download


  1. or download this
    $count++ while ($str=~ /$pattern/g);       # simple
    
  2. or download this
    $count=  (scalar split /$pattern/, $str )
           + ($str=~/$pattern$/)               # or it will not be counted
           - 1;                                # so it's simpler