> On Mar 2, 2015, at 4:52 PM, Keary Suska <cocoa-...@esoteritech.com> wrote: > > That depends on what you mean by "validate." If you simply mean checking > whether it well-formed, you can do that easily with a regular expression > match, such as (written in email): > ^http://(?:[a-z0-9-]+\.){1,}[a-z]{2,4}
It’s really much better to ask the system frameworks to do this kind of checking/parsing, since they are more likely than you are to know all the nuances of the RFCs. For instance, your regex above won’t work with international domain names, or capitalized forms of domain names, or top-level domains longer than 4 characters, or single-component domains like “foo”... (I’m not saying this to pick on you, just warning people who might come across this thread in a web-search and copy and paste your regex. I’m sure it would also take me a while to write a regex that could reliably match domain names, assuming I even decided to try; that’s part of my point.) —Jens _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com