Prev: NetBeans Question
Next: Another NetBeans Question
From: Richard Quadling on 1 Jun 2010 11:33 On 1 June 2010 16:31, Richard Quadling <rquadling(a)gmail.com> wrote: > $re1 = '/^[a-z]++$/i'; ^[a-z]++$ Options: case insensitive; ^ and $ match at line breaks Assert position at the beginning of a line (at beginning of the string or after a line break character) «^» Match a single character in the range between âaâ and âzâ «[a-z]++» Between one and unlimited times, as many times as possible, without giving back (possessive) «++» Assert position at the end of a line (at the end of the string or before a line break character) «$» > $re2 = '/^[a-z ]++$/i'; ^[a-z ]++$ Options: case insensitive; ^ and $ match at line breaks Assert position at the beginning of a line (at beginning of the string or after a line break character) «^» Match a single character present in the list below «[a-z ]++» Between one and unlimited times, as many times as possible, without giving back (possessive) «++» A character in the range between âaâ and âzâ «a-z» The character â â « » Assert position at the end of a line (at the end of the string or before a line break character) «$» -- ----- 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
From: Richard Quadling on 1 Jun 2010 11:35 On 1 June 2010 16:33, Ashley Sheridan <ash(a)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
From: Peter Lind on 1 Jun 2010 11:36 On 1 June 2010 17:33, Ashley Sheridan <ash(a)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? > Equally important: why have three people already done this persons homework. 5 minutes googling would have answered this ... -- <hype> WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 </hype>
From: Ashley Sheridan on 1 Jun 2010 11:38 On Tue, 2010-06-01 at 16:35 +0100, Richard Quadling wrote: > On 1 June 2010 16:33, Ashley Sheridan <ash(a)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 Ah, I ought to have guessed as it's you! ;) I didn't know about that in regex's, I've learnt something new today! Thanks, Ash http://www.ashleysheridan.co.uk
From: Richard Quadling on 1 Jun 2010 12:32
On 1 June 2010 16:38, Ashley Sheridan <ash(a)ashleysheridan.co.uk> wrote: > Ah, I ought to have guessed as it's you! ;) What are you insinuating? -- ----- 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 |