Re: preg_split() - pattern problem

From: Date: Mon, 11 Nov 2002 19:10:11 +0000
Subject: Re: preg_split() - pattern problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-123861@lists.php.net to get a copy of this message
I believe it's U so try /T.*0.*B/U -js Jason Wong wrote: > On Tuesday 12 November 2002 02:26, Tobias Talltorp wrote: > >>How would I write the pattern for this preg_split()? >>"/T.*O.*B/", seems to only return the first and last portion of the string >>(1: Once upon a time, 2: going for a walk). >> >>$string = "Once upon a time T:O.B there was a T.O,B duck who was T-O'B >>going for a walk"; >> >>$array = preg_split('/T.*O.*B/', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); > > > It's doing a greedy match, thus your pattern is actually matching > > {T:O.B there was a T.O,B duck who was T-O'B} > > 1) Check whether there's a flag in PRCE to do ungreedy matches. > > or > > 2) Maybe you really meant your pattern to be /T.O.B/ which matches > > T{any single char}O{any single char}B > >

« previous php.general (#123861) next »