Req #55654 [NEW]: ereg() behavior for preg_match
| From: | imaggens at gmail dot com | Date: | Fri, 09 Sep 2011 12:30:43 +0000 |
| Subject: | Req #55654 [NEW]: ereg() behavior for preg_match | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-163411@lists.php.net to get a copy of this message | ||
From:
Operating system: Windows 7
PHP version: 5.3SVN-2011-09-09 (snap)
Package: Regexps related
Bug Type: Feature/Change Request
Bug description:ereg() behavior for preg_match
Description:
------------
Consideration. I choosen "September Snapshot", because I could not find
mine in
the
list. My installation report to "PHP 5.3.3. Build Date: Jul 21 2010
20:25:38".
Alright.
I would like to ask, if is there any possibility to add, maybe through
another
non-Perl compatible modifier, the behavior we had with ereg().
The behavior I'm talking about refers to match as much as possible instead
of
stop at very first valid match.
This is useful sometimes. In my case, specially to validate input data
against a
RFC specification.
Look at this snippet: https://ideone.com/sC6mA
I tried to make it as much specific as I could.
The intention was to validate float point numbers, between zero and 1, with
none
and up to three decimals, denying invalid floats, such as 0.00 (same as
zero) or
1.0 (same as 1).
But, the "lazy" behavior of preg_match() is accepting the code above, where
0.3444 should be denied, because of its 4 decimals.
But since 0.344 is valid in the last length verification (one and up to
three),
the function accepts the input data, and the last digit is simply ignored,
because preg_match() already caracterized 0.344 as valid.
I hope you understand
Expected result:
----------------
An empty array
Actual result:
--------------
A match
--
Edit bug report at https://bugs.php.net/bug.php?id=55654&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55654&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55654&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55654&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=55654&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55654&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=55654&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=55654&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=55654&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=55654&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=55654&r=support
Expected behavior: https://bugs.php.net/fix.php?id=55654&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=55654&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=55654&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=55654&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55654&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55654&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=55654&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=55654&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=55654&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=55654&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=55654&r=mysqlcfg