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

Home » Imported messages » comp.lang.php » regexp
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
regexp [message #173491] Fri, 15 April 2011 19:51 Go to next message
smerf is currently offline  smerf
Messages: 12
Registered: January 2011
Karma: 0
Junior Member
["regexp"]=>
string(93) "^/(?Particles|admin/comments|blog)(/(?P[^/]+?)?(/(?P[^/]+?)?)?)?(/)?$"

What is making "?P" above ?
Re: regexp [message #173493 is a reply to message #173491] Fri, 15 April 2011 19:59 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 15-04-2011 21:51, smerf wrote:
> ["regexp"]=>
> string(93)
> "^/(?Particles|admin/comments|blog)(/(?P[^/]+?)?(/(?P[^/]+?)?)?)?(/)?$"
>
> What is making "?P" above ?

no sure

but maybe this page gives answers?:
http://www.php.net/manual/en/regexp.reference.meta.php

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




--
Luuk
Re: regexp [message #173496 is a reply to message #173491] Fri, 15 April 2011 21:21 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.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
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: 0
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
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Sun Nov 10 13:33:35 GMT 2024

Total time taken to generate the page: 0.02731 seconds