Very nice. I was going to suggest: <?php
$input = "wed-thurs 9:35, 14:56, 18:35, 21, 22, 23:59"; preg_match( "/([a-z]+)-([a-z]+)((?:\s[0-9]+(?::[0-9]+)?,?)*)/", $input, $output, PREG_SET_ORDER ); $output[3] = preg_replace( "/,/", "", trim($output[3]) ); $times = explode( " ", $output[3] ); ?> But uhhh, your way is much nicer :] ----- Original Message ----- From: "Richard Archer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, March 26, 2002 4:04 AM Subject: Re: [PHP] Regular Expression Challenge > At 11:30 AM +1000 26/3/02, Cameron Just wrote: > > >I was not sure as to whether regexp could do recursive matching and now I > >know. > > This is crazy! There used to be clue on this list! > > <?php > > $test = "wed-thurs 9:35, 14:56, 18:35, 6, :12"; > > $patt = "/([a-z]+|[0-9]*:*[0-9]+)[ ,-]*/"; > > if (preg_match_all ($patt, $test, $tok)) { > while (list($k, $v) = each($tok[1])) { > echo "\$tok[$k] = $v<br>\n"; > } > } > > ?> > > Output: > $tok[0] = wed > $tok[1] = thurs > $tok[2] = 9:35 > $tok[3] = 14:56 > $tok[4] = 18:35 > $tok[5] = 6 > $tok[6] = :12 > > ...R. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php