NYCPHP Meetup

NYPHP.org

[nycphp-talk] validating proper name capitalization

Jake McGraw jmcgraw1 at gmail.com
Fri Sep 23 09:58:15 EDT 2011


$proper_name = ucwords(strtolower($fullname));

Of course this messes up names like mine (Jake McGraw becomes Jake Mcgraw),
but, I'm used to it :(

jake

On Fri, Sep 23, 2011 at 9:54 AM, David Mintz <david at davidmintz.org> wrote:

>
> I'm trying to require users to input proper names with capitalization that
> conforms to convention. So, you can't go e. e. cummings on me, and you can't
> be JOHN SOMEBODY either. And you can't have your caps lock on and enter jOHN
> sOMEBODY. That much is pretty easy, but I am finding the more subtle cases
> pretty hard.
>
> So far, I have
>
>         /\b[a-z][A-Z]+|\b[A-Z]{2,}+|^[a-z ]+$/
>
> to test against (false is good). This works on all the cases I have tested
> except "cuMmings," which gets by. But I am thinking, maybe enough is enough;
> you can't control everything.
>
> Just wondering if anyone has tackled this before or has any thoughts.
>
> btw this is on top of other whitelist-style validation.
>
> --
> David Mintz
> http://davidmintz.org/
> It ain't over:
> http://www.healthcare-now.org/
>
>
>
> _______________________________________________
> New York PHP Users Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/Show-Participation
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20110923/a6ae0822/attachment.html>


More information about the talk mailing list