Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-16-2010, 12:46 AM   PM User | #1
johnnnn
New Coder

 
Join Date: May 2009
Location: Pennsylvania, United States
Posts: 54
Thanks: 16
Thanked 0 Times in 0 Posts
johnnnn is an unknown quantity at this point
Question Quick PHP regex question!

I'm using the following snippet as an example from the manual:

PHP Code:
preg_match('@^(?:http://)?([^/]+)@i',
    
"http://www.php.net/index.html"$matches); 
My question is, what does the ?: before http:// do?
Thanks
johnnnn is offline   Reply With Quote
Old 04-16-2010, 01:04 AM   PM User | #2
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
It makes the parantheses non capturing.
MattF is offline   Reply With Quote
Old 04-16-2010, 06:55 AM   PM User | #3
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
i.e. $1 will not equal to 'http://' but to '[^/]+'
without '?:' $1 will equal to 'http://' and $2 will equal to '[^/]+'
__________________
Website Design Mansfield
PHP Code:
function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
echo 
I_LOVE(); 
Phil Jackson is offline   Reply With Quote
Reply

Bookmarks

Tags
expression, php, regex, regular

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:13 AM.


Advertisement
Log in to turn off these ads.