Re: NSURL and NSRegularExpression

2012-03-04 Thread R
Thanks Per. I've got a decent solution using Data Detectors as per the advice from above. I'm just looking to at least match Twitters iOS approach, which is not accomplished by using Data Detectors alone. Thanks again -- Ron On Mar 4, 10:14 am, Per Bull Holmen wrote: > Den 17:43 4. mars 2012 s

Re: NSURL and NSRegularExpression

2012-03-04 Thread Jens Alfke
On Mar 4, 2012, at 8:43 AM, R wrote: > You no longer have to shorten an URL before sending it to Twitter... > but if you do such, realizing perfect is not the goal, you should do > reasonable dueDiligence on the quality of the URL. Oh, this is about URL shortening? I’m strongly against that prac

Re: NSURL and NSRegularExpression

2012-03-04 Thread Per Bull Holmen
Den 17:43 4. mars 2012 skrev R følgende: > Take a look at the Twitter iPhone app.  Enter a URL and watch how it > deals with character counts. I don't have an iPhone, I don't use Twitter, and we are not a paid heldesk company. If you want help, you have to specify precisely the problem that you

Re: NSURL and NSRegularExpression

2012-03-04 Thread R
You no longer have to shorten an URL before sending it to Twitter... but if you do such, realizing perfect is not the goal, you should do reasonable dueDiligence on the quality of the URL. Take a look at the Twitter iPhone app. Enter a URL and watch how it deals with character counts. On Mar 4,

Re: NSURL and NSRegularExpression

2012-03-04 Thread Per Bull Holmen
Den 04:27 4. mars 2012 skrev R følgende: > All good, valid and useful points. > > However, I would at least like to maintain the same functionality of > the Twitter App for iPhone. > > The app does does a pretty good job of detecting and reviewing the URL > to determine if it can be assumed to be

Re: NSURL and NSRegularExpression

2012-03-03 Thread R
All good, valid and useful points. However, I would at least like to maintain the same functionality of the Twitter App for iPhone. The app does does a pretty good job of detecting and reviewing the URL to determine if it can be assumed to be 20 characters. On Mar 3, 7:16 pm, Conrad Shultz wrot

Re: NSURL and NSRegularExpression

2012-03-03 Thread Conrad Shultz
On 3/3/12 5:48 PM, Jens Alfke wrote: > Look up the hostname. No ping required. As I mentioned in the reply I just posted, even looking up the hostname is potentially problematic. One obvious case that I overlooked in my response: mandatory hostname lookup will cripple your functionality if you do

Re: NSURL and NSRegularExpression

2012-03-03 Thread Per Bull Holmen
Den 02:55 4. mars 2012 skrev Jens Alfke følgende: > > I’d much rather people used a system library, or at least searched around to > find a really good and well-tested regexp that other apps have used. It’s > annoying when an app can’t highlight a URL properly, especially on iOS where > it’s reall

Re: NSURL and NSRegularExpression

2012-03-03 Thread Conrad Shultz
On 3/3/12 5:06 PM, R wrote: > Thanks Conrad, much cleaner indeed. But, this does not solve my > invalid internet URL issues still accepts pretty much any URL. I don't understand what you mean by "invalid." I would expect that NSDataDetector has been pretty thoroughly tested and will not matc

Re: NSURL and NSRegularExpression

2012-03-03 Thread Jens Alfke
On Mar 3, 2012, at 5:42 PM, Per Bull Holmen wrote: > How about just work with your regular expressions > and try to narrow down the patterns it will accept? I’d much rather people used a system library, or at least searched around to find a really good and well-tested regexp that other apps hav

Re: NSURL and NSRegularExpression

2012-03-03 Thread Jens Alfke
On Mar 3, 2012, at 4:15 PM, R wrote: > 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

Re: NSURL and NSRegularExpression

2012-03-03 Thread Per Bull Holmen
Den 02:06 4. mars 2012 skrev R følgende: > Thanks Conrad, much cleaner indeed.  But, this does not solve my > invalid internet URL issues still accepts pretty much any URL. Just a little suggestion: How about not trying to be perfect? My mail client (Google mail) also accepts your Bad URL exa

Re: NSURL and NSRegularExpression

2012-03-03 Thread R
Thanks Conrad, much cleaner indeed. But, this does not solve my invalid internet URL issues still accepts pretty much any URL. I'm wondering how Twitter IOS, and TWTweetComposeViewController handles URL counting. On Mar 3, 5:30 pm, Conrad Shultz wrote: > Don't do all this. Use NSDataDetecto

Re: NSURL and NSRegularExpression

2012-03-03 Thread Conrad Shultz
Don't do all this. Use NSDataDetector instead. (Sent from my iPhone.) -- Conrad Shultz On Mar 3, 2012, at 16:15, R wrote: > 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

NSURL and NSRegularExpression

2012-03-03 Thread R
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