Re: regular expression
| From: | Richard Quadling | Date: | Tue, 01 Jun 2010 15:35:09 +0000 |
| Subject: | Re: regular expression | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305698@lists.php.net to get a copy of this message | ||
On 1 June 2010 16:33, Ashley Sheridan <ash@ashleysheridan.co.uk> wrote:
>
> On Tue, 2010-06-01 at 16:31 +0100, Richard Quadling wrote:
>
> $re1 = '/^[a-z]++$/i';
> $re2 = '/^[a-z ]++$/i';
>
>
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer :
> http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
>
> Why the double ++ in the expressions there? Surely one + would match the 1 or more characters
> that you need and the second one would just be surplus?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
++ doesn't give back. As there is no need to do any backtracking, this
is supposed to be a slight optimization.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling