|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-09-09 12:30 UTC] imaggens at gmail dot com
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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 04:00:01 2025 UTC |
Actually, your regex might match up to four decimal digits (\.[1-9][1-9]{1,3}). A probably suitable regex can be seen on <http://3v4l.org/GZ9MZ>. Anyhow, I'm closing this request, because I consider it highly unlikely and unnecessary that a simplified regex syntax will be made available for the PCRE implementation.