count#

Count non-overlapping matches of the pattern in a subject string.

The whole scan loop runs natively: one method call per subject, not one per match. Empty matches are counted the way a global match ought to: after an empty match the scan retries at the same offset with PCRE2_NOTEMPTY_ATSTART|PCRE2_ANCHORED and then advances one character (the pcre2demo.c idiom), stepping over a whole UTF-8 character or CRLF pair where applicable.

Synopsis#

my $n = Peta::PCRE2->new("agggtaaa|tttaccct", PCRE2_CASELESS)
                   ->count($genome);