Reg Ex to search for both Integer and Comma-spaced Integer
| From: | Kevin Stone | Date: | Tue, 01 Jul 2003 17:07:11 +0000 |
| Subject: | Reg Ex to search for both Integer and Comma-spaced Integer | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153585@lists.php.net to get a copy of this message | ||
I'm a little confused by something. I need to build a reg-ex to scrape for
both plain integers and comma spaced integers in the same place in the same
string at the same time. For example..
$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?
Thanks!
- Kevin