Re: Reg Ex to search for both Integer and Comma-spaced Integer

From: Date: Tue, 01 Jul 2003 18:35:02 +0000
Subject: Re: Reg Ex to search for both Integer and Comma-spaced Integer
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-153600@lists.php.net to get a copy of this message
----- Original Message ----- From: "Ford, Mike [LSS]" <M.Ford@lmu.ac.uk> To: "'Kevin Stone'" <kevin@helpelf.com>; "PHP-General" <php-general@lists.php.net> Sent: Tuesday, July 01, 2003 12:19 PM Subject: RE: [PHP] Reg Ex to search for both Integer and Comma-spaced Integer > > -----Original Message----- > > From: Kevin Stone [mailto:kevin@helpelf.com] > > Sent: 01 July 2003 18:07 > > > > $string = "Mark's average score was 544."; > > preg_match("/average score was ([0-9]+)/", $string, $matches); > > $score = $matches(1); > > > > $string = "Julie's average score was 10,443."; > > preg_match("/average score was ([0-9]+,[0-9]+)/", $string, $matches); > > $score = $matches(1); > > > > How do I combine these two queries so that the reg-ex matches > > both the comma > > spaced integer and regular integer? > > preg_match("/average score was ([0-9]+(,[0-9]+)*)/", $string, $matches); > > should do it. > > Cheers! > > Mike Excelent thinking Mike that's exactly the result I was after. Thanks! - Kevin

« previous php.general (#153600) next »