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 -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Save energy: be apathetic. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php