|
Posted by John Nichel on 11/14/24 11:22
André Medeiros wrote:
> On Wed, 2005-07-27 at 11:55 -0400, John Nichel wrote:
>
>>André Medeiros wrote:
>>
>>>That's not very nice of you, saying that to people who try to help ;)
>>>
>>>if( strpos( $_POST['frmName'], ' ' ) === false ) {
>>> // Do error handling here
>>>} else {
>>> // All is OK :)
>>>}
>>>
>>
>>How does that match "Firstname Lastname" better than a regex? That will
>>return true as long as there is at least one space, no matter what the
>>rest of the submission is. I could submit "$^&#^&$&#& )(*!@#", or I
>>could submit just a single space, and that would return true. strpos()
>>has it's uses, but this isn't one of them.
>
> There is a large number of sittuations that the regex won't work in.
> Special characters aren't included (from what I can understand using my
> weak regex knowlege), you could even be chinese, and it wouldn't work.
>
> If you use strpos with trim and strlen cleverlly, you won't have to
> worry about it again.
>
> My $0.02
You can trim whitespace and check the length until the cows come home,
and that still won't stop a string such as "#T*& a%@!". A regex can
cover practicaly every situation for a name submission; it all depends
on how deep you want to validate. strpos() has too narrow of a scope to
match a complex pattern.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@kegworks.com
[Back to original message]
|