|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-08 13:19 UTC] nlopess@php.net
[2004-07-11 08:32 UTC] info at smithfieldentertainment dot com
[2004-07-12 10:09 UTC] vrana@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Description: ------------ I sent the following email to Mehdi Achour <didou@keliglia.com> --------------- Hi, I discovered (the hard way after hours of code troubleshooting) that ereg/eregi/etc. functions have a very useful but LIMITED length function. It seems that while the ereg functions will search for matches in (any?) length code, the length limiter {0, 255} is limited to 255. I was trying to match lengths of 350 and 800? but couldn?t figure out why I was getting an error. There?s no documentation on this anywhere that I could find. Please add it to all applicable regular expression match items that it applies to. Thanks! -- CJ Greiner info@SmithfieldEntertainment.com http://www.SmithfieldEntertainment.com 757-356-1166 Reproduce code: --------------- if (eregi("^([a-z0-9 $&*?\'.-]{100,300})$", $register_data[register_summary], $ereg_results) == FALSE) { $error_message .= '<br>Subject Summary: Please use only letters, numbers, and punctuation: \'-$&*?<br>'; } Expected result: ---------------- if the user input $register_data[register_summary] does not match the regular expression OR is ouside the acceptable length range of 100-300 letters, then the expression should return FALSE and assign an $error_message. Actual result: -------------- Even when the user input for $register_data[register_summary] had acceptable characters AND had acceptable lengths... The code failed because the max length of 300 {100, 300} was causing a FALSE or FAIL. I experimented with the length until I brought it down to 255... then it worked. This limit is not documented anywhere. There should be no limit... or at least a much higher limit, since the matching expression will work on a much longer string if no length limit is placed in it. Thanks!