Perl-совместимые регулярные выражения (Perl-compatible regular expressions)
FINDING ALL POSSIBLE MATCHES
The traditional matching function uses a similar algorithm to
Perl, which stops when it finds the first match, starting at a
given point in the subject. If you want to find all possible
matches, or the longest possible match, consider using the
alternative matching function (see below) instead. If you cannot
use the alternative function, but still need to find all possible
matches, you can kludge it up by making use of the callout
facility, which is described in the pcrecallout
documentation.
What you have to do is to insert a callout right at the end of
the pattern. When your callout function is called, extract and
save the current matched substring. Then return 1, which forces
pcre_exec()
to backtrack and try other alternatives. Ultimately,
when it runs out of matches, pcre_exec()
will yield
PCRE_ERROR_NOMATCH.