RE: [PHP] HELP!
| From: | Kim Madsen | Date: | Wed, 30 Mar 2005 10:17:10 +0000 |
| Subject: | RE: [PHP] HELP! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-211857@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: 王成乔 [mailto:wangchq@china-channel.com]
> Sent: Wednesday, March 30, 2005 11:46 AM
> To: php-general@lists.php.net
> Cc: php-general@lists.php.net
Why to AND cc?
> Would somebone give me a example of regulation expression to check
> account(or money) type which start with “$”.
> For example, “$65,786.00”
Same question was asked yesterday?
$str = "$65,786.00";
if(ereg("^([\$]([0-9]+,)?[0-9]+\.[0-9]+)",$str, $pricetag))
print "we found a price tag: $pricetag[1]";
else
print "no prices found";
This is untested, the ([0-9]+,)? Means that there _may_ be digits and then a komma, but it´s not
necessary, threfore $786.00 and $1.00 matches too. The () around all expressions means, that we save
whatever is matched into $pricetag
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/systemdeveloper