Re: Regular Expression Challenge

From: Date: Tue, 26 Mar 2002 04:04:01 +0000
Subject: Re: Regular Expression Challenge
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-90150@lists.php.net to get a copy of this message
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.

« previous php.general (#90150) next »