RE: [PHP] Reg Ex to search for both Integer and Comma-spaced Inte ger

From: Date: Tue, 01 Jul 2003 18:19:52 +0000
Subject: RE: [PHP] Reg Ex to search for both Integer and Comma-spaced Inte ger
Groups: php.general 
Request: Send a blank email to php-general+get-153599@lists.php.net to get a copy of this message
> -----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 --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#153599) next »