harshmane has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: to find string
by Ratazong (Monsignor) on Jun 21, 2011 at 05:56 UTC
    What have you tried? Are you aware of index? That should find your substring. And by providing an offset in combination with a loop, counting the number of occurences should be not too difficult ...
Re: to find string
by ikegami (Patriarch) on Jun 21, 2011 at 06:28 UTC

    How many "abab" are "abababab"?

    2:

    # abababab # ---- # ---- my $count = 0; ++$count while $string =~ /\Q$substr/g;

    3:

    # abababab # ---- # ---- # ---- local our $count = 0; $string =~ /\Q$substr\E(?{ ++$count })(?!)/;
Re: to find string
by toolic (Bishop) on Jun 21, 2011 at 13:04 UTC
Re: to find string
by GrandFather (Saint) on Jun 21, 2011 at 05:57 UTC

    Show us what you tried.

    True laziness is hard work
Re: to find string
by Anonymous Monk on Jun 21, 2011 at 06:01 UTC