note 26403 added to pcre.pattern.syntax
| From: | apass at rack1 dot php dot net | Date: | Tue, 29 Oct 2002 22:12:50 +0000 |
| Subject: | note 26403 added to pcre.pattern.syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38719@lists.php.net to get a copy of this message | ||
Having problems with "?" wiping out (invalidating) your match? This proved invalid for
me...
"Because it [?] has two uses, it can sometimes appear doubled, as in
\d??\d
which matches one digit by preference, but can match two if that is the only way the rest of the
pattern matches."
Here's how: "(?:.*fax\s(.*))" would match this "fax 212-966-5349 ", but
this wouldn't match it: "(?:.*fax\s(.*))?". The "?" was supposed to let
either 0 or 1 matches get caught, but only this would let that happen:
"(?:.*fax\s(.*))??".
Go figure. Sometimes "??" is better than "?"!
--
http://www.php.net/manual/en/pcre.pattern.syntax.php
http://master.php.net/manage/user-notes.php?action=edit+26403
http://master.php.net/manage/user-notes.php?action=delete+26403
http://master.php.net/manage/user-notes.php?action=reject+26403