Help for this page

Select Code to Download


  1. or download this
    How can I count the number of occurrences of a substring within a stri
    +ng?
    There are a number of ways, with varying efficiency. If you want a cou
    +nt
    ...
    result to a scalar, producing a count of the number of matches.
    
            $count = () = $string =~ /-\d+/g;