note 59755 added to function.ereg
| From: | ar_cat at shaw dot ca | Date: | Wed, 14 Dec 2005 23:13:08 +0000 |
| Subject: | note 59755 added to function.ereg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100167@lists.php.net to get a copy of this message | ||
I had problem using is_numeric() to verify if user inputs is a number (including optional floating
sign and decimals). Instead I found this expression from http://www.regular-expressions.info/floatingpoint.html
and modified it for a bit.
^[+-]?[0-9]*\.?[0-9]+$
/*
3.55 true
-3.55 true
+3.55 true
2456.90 true
34skd false
23. false
2dt6 false
*/
Note: mine doesn't have the exponent part; for matching number with exponents, visit the site
above :)
----
Manual Page -- http://www.php.net/manual/en/function.ereg.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59755
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59755&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59755&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59755&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59755&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59755&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59755&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59755&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59755&report=yes
Search -- http://master.php.net/manage/user-notes.php