Reply to Regular expression example on PHP.net

Your name:

Reply:


Posted by Zenofobe on 09/07/07 06:02

Howdy folks,

On this page at php.net
http://www.php.net/features.http-auth
there's a regular expression in Example 34.2. It's supposed to parse out
the different values being passed in the header. I know what it's
supposed to do, so I have a vague idea of what's being done in the RE,
but I've been having a heck of a time figuring out what each part of the
RE is actually doing. Here's what I have so far:

preg_match_all('@(\w+)=(?:([\'"])([^\2]+)\2|([^\s,]+))@', $txt, $matches,
PREG_SET_ORDER);

//'@
//(\w+) Any word character (letter/digit/_), 1 or more
//= Equal sign
//(?: This submatch will not be captured (still available for
later matching)
//([\'"]) A single or double quote
//([^\2]+) Not start of text (STX)?, 1 or more
//\2|
//([^\s,]+) Not whitespace or comma, 1 or more
//)
//@'

I'm unclear as to what the second \2 does, as well as which parts the OR
applies to. And what are the @s for?

Thanks for any help,
ZF

--
Posted via a free Usenet account from http://www.teranews.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация