Auteur: jonetsu Date: À: pcre-dev Sujet: [pcre-dev] Using pcre: the /g behaviour
Hello,
Some guidance about using pcre would be much appreciated.
I am trying to extract values from a string (eventually strings
separated by Unix newlines) and found out about the named substrings,
which seems to be great, as I saw using pcredemo:
Match succeeded at offset 14
0: rate 300000Kbit
1: 300000
Named substrings
(1) rate: 300000
But there's more than the rate to extract and this is where I haven't
found how to duplicate the behaviour of continuing a search, when using
pcredemo.
pcretest can do it, in this case finding both rate and ceil values by
adding the /g switch to the expression:
Match succeeded at offset 14
0: rate 300000Kbit
1: 300000
I have tried with the PCRE_NOTEMPTY_ATSTART|PCRE_ANCHORED options for
pcre_exec() but to no avail (eg. 'no match').
About this I have two questions:
1) How can the /g option be added to pcredemo ?
2) In the case of the finding both rate and ceil values as with
pcretest above, how come the vector index is again at 0 for the ceil
value and, what would the 'unset' mean ? I presume that if I name
those substring (pcretest does not seem to observe naming substrings)
then I would simply retrieve by name and not really bother about
'unset' values and index values.