|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-28 20:58 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 04:00:02 2025 UTC |
Description: ------------ I'm using quantifiers in preg_match_all functions,amongst other things, to restrict the length of strings strings submitted from HTML forms. The lower limit catches discrepant strings, but the upper limit has no effect. I've tried using very basic code, but unsuccessfully. Reproduce code: --------------- $failure = 0; $userpattern = "/t{3,6}/"; $username = 'ttttttt'; $usercheck = preg_match_all($userpattern,$username,$results); if ( !$usercheck ) { $failure++; } Expected result: ---------------- $usercheck = 'tt'; This would be a disallowed string $usercheck = 'ttttttt'; This would also be a disallowed string Actual result: -------------- $usercheck = 'tt'; results in $failure == 1 & the string 'fails' as it should. $usercheck = 'ttttttt'; results in $failure = 0 & the string is allowed. This happens however many repetitions the string comprises and with any upper limit set.