NSURL and NSRegularExpression
NSURL and NSRegularExpression
- Subject: NSURL and NSRegularExpression
- From: R <email@hidden>
- Date: Sat, 03 Mar 2012 16:15:16 -0800 (PST)
I'm building a twitter app for the iphone and want to detect valid
internet url's and set their character count to <= 20.
I'm using NSRegularExpression to build an array of all NSRanges in the
text field that start with "http". I then use NSScanner to scan until
it finds whitespace or end of line characters for each
range.location. I then place this new subString into a NSURL to
validate that it does not return nil.
I'm finding that NSURL pretty much likes everything.....
http://www.cnn.thePiratesWillWinTheWorldSeries is happy.
Is there a good way to validate a NSURL for the internet, short of
pinging?
My next step is to find the end of the substring, count back three
characters and check for com,edu or org... seems clunky and inaccurate
for future internet standards.
Thanks -- Ron
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden