note 74700 added to function.is-numeric

From: Date: Tue, 24 Apr 2007 08:33:34 +0000
Subject: note 74700 added to function.is-numeric
Groups: php.notes 
Request: Send a blank email to php-notes+get-125823@lists.php.net to get a copy of this message
a regex doing the same as is_numeric() is: "^((-?[0-9]*\.[0-9]+|[[:space:]]*[+-]?[0-9]+(\.[0-9]*)?) ([eE][+-]?[0-9]+)?|0x[0-9a-fA-F]+)$" (took me some testing to figure this out) regex: "^(decimal|hex)$" decimal: "(base1|base2)(exponent)?" base1: "-?[0-9]*\.[0-9]+" if there are no prepanded spaces and no "+" the base may be any of "0", ".0", "0.0". base2: "[[:space:]]*[+-]?[0-9]+(\.[0-9]*)?" if there are empty spaces or a "+" prepanded the base may only be "0" or "0.0" (no idea why) exponent: "[eE][+-]?[0-9]+" the exponent is opional hex: "0x[0-9a-fA-F]+" usage: preg_match("/regex/D", $str); or ereg("regex", $str); Just to know what is_numeric() is doing. Of cause the regex should be much slower and is_numeric() also returns false if the number would be to big to fit into a double. ---- Server IP: 69.147.83.197 Probable Submitter: 84.158.72.243 ---- Manual Page -- http://www.php.net/manual/en/function.is-numeric.php Edit -- https://master.php.net/note/edit/74700 Del: integrated -- https://master.php.net/note/delete/74700/integrated Del: useless -- https://master.php.net/note/delete/74700/useless Del: bad code -- https://master.php.net/note/delete/74700/bad+code Del: spam -- https://master.php.net/note/delete/74700/spam Del: non-english -- https://master.php.net/note/delete/74700/non-english Del: in docs -- https://master.php.net/note/delete/74700/in+docs Del: other reasons-- https://master.php.net/note/delete/74700 Reject -- https://master.php.net/note/reject/74700 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125823) next »