Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

What is making "?P" above ?

Re: regexp

On 15-04-2011 21:51, smerf wrote:
Quoted text here. Click to load it

no sure

but maybe this page gives answers?:

    extends the meaning of (, also 0 or 1 quantifier, also makes greedy
quantifiers lazy (see repetition)


Re: regexp


Quoted text here. Click to load it

Usually ?P is used to give a name to a subpattern, e.g.


This match can then be accessed by the name 'foo' in the result set. But
in the above example there are no names given, so I'm not sure what the
?Ps are supposed to do there.


Re: regexp

On 15-04-2011 23:21, Michael Fesser wrote:
Quoted text here. Click to load it

hm i learned something today ;)

"It is possible to name a subpattern using the syntax (?P<name>pattern).
This subpattern will then be indexed in the matches array by its normal
numeric position and also by name. PHP 5.2.2 introduced two alternative
syntaxes (?<name>pattern) and (?'name'pattern)."

Too bad that some simple example are missing for this 'complex'stuff.... ;)


Site Timeline