Autor: Philip Hazel Datum: To: George Zhuravlev CC: Philip Hazel Betreff: Re: [pcre-dev] please,
advice me PCRE discussion forums or groups (fwd)
On Mon, 26 Mar 2007, George Zhuravlev wrote:
> PH> It cannot. The iteration must be done in the program that calls PCRE. > I have one! (in process of writing, to be exact). But what function calls
> can provide me such an information? If I call pcre_get_substring() I only
> get the last match of this group - "3.", that's all. Do the PCRE
> library store first two matches ("1.", "2.") anywhere? Or is there an
> alternative way to get this info?
The pcre_exec() function finds ONE match only. It stops when it has
found one match. Therefore:
Call pcre_exec(). It returns the offset of the first match. Extract any
substrings that you need. Then call pcre_exec() again, setting the
startoffset argument beyond the first match, and the PCRE_NOTBOL option.
It will return the offset of the second match ... and so on.
Philip
--
Philip Hazel, University of Cambridge Computing Service.