Home »
Imported messages »
comp.lang.php »
regexp
Re: regexp [message #173507 is a reply to message #173496] |
Sat, 16 April 2011 08:08 |
Luuk
Messages: 329 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 15-04-2011 23:21, Michael Fesser wrote:
> .oO(smerf)
>
>> ["regexp"]=>
>> string(93) "^/(?Particles|admin/comments|blog)(/(?P[^/]+?)?(/(?P[^/]+?)?)?)?(/)?$"
>>
>> What is making "?P" above ?
>
> Usually ?P is used to give a name to a subpattern, e.g.
>
> (?P<foo>.*)
>
> 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.
>
> Micha
hm i learned something today ;)
http://www.php.net/manual/en/regexp.reference.subpatterns.php
"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.... ;)
--
Luuk
|
|
|
Goto Forum:
Current Time: Sun Nov 10 16:34:18 GMT 2024
Total time taken to generate the page: 0.04260 seconds