note 88041 added to function.is-numeric
| From: | MagnusDeininger at osu1 dot php dot net | Date: | Wed, 07 Jan 2009 14:01:40 +0000 |
| Subject: | note 88041 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148918@lists.php.net to get a copy of this message | ||
regarding the global vs. american numeral notations, it should be noted that at least in japanese,
numbers aren't grouped with an extra symbol every three digits, but rather every four digits
(for example 1,0000 instead of 10.000). also nadim's regexen are slightly suboptimal at one
point having an unescaped '.' operator, and the whole thing could easily be combined into
a single regex (speed and all).
adjustments:
$eng_or_world = preg_match
('/^[+-]?'. // start marker and sign prefix
'(((([0-9]+)|([0-9]{1,4}(,[0-9]{3,4})+)))?(\\.[0-9])?([0-9]*)|'. // american
'((([0-9]+)|([0-9]{1,4}(\\.[0-9]{3,4})+)))?(,[0-9])?([0-9]*))'. // world
'(e[0-9]+)?'. // exponent
'$/', // end marker
$str) == 1;
i'm sure this still isn't optimal, but it should also cover japanese-style numerals and it
fixed a couple of other issues with the other regexen. it also allows for an exponent suffix, the
pre-decimal digits are optional and it enforces using either grouped or ungrouped integer parts.
should be easier to trim to your liking too.
----
Server IP: 217.13.201.10
Probable Submitter: 91.32.104.32
----
Manual Page -- http://www.php.net/manual/en/function.is-numeric.php
Edit -- https://master.php.net/note/edit/88041
Del: integrated -- https://master.php.net/note/delete/88041/integrated
Del: useless -- https://master.php.net/note/delete/88041/useless
Del: bad code -- https://master.php.net/note/delete/88041/bad+code
Del: spam -- https://master.php.net/note/delete/88041/spam
Del: non-english -- https://master.php.net/note/delete/88041/non-english
Del: in docs -- https://master.php.net/note/delete/88041/in+docs
Del: other reasons-- https://master.php.net/note/delete/88041
Reject -- https://master.php.net/note/reject/88041
Search -- https://master.php.net/manage/user-notes.php