FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » regexp
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: regexp [message #173507 is a reply to message #173496] Sat, 16 April 2011 08:08 Go to previous message
Luuk is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Why no Text after image 1?
Next Topic: Figure out path to php.ini
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 14:21:23 GMT 2024

Total time taken to generate the page: 0.04553 seconds