1

I've implemented NSDataDetector to detect URLs, but it includes email addresses as well. Is there an easy way to make it not detect emails, but all other URLs?

jscs
  • 62,161
  • 12
  • 145
  • 186
user212541
  • 1,798
  • 1
  • 20
  • 29
  • See Dave DeLong's answer to this stack overflow question: [NSDataDetector with NSTextCheckingTypeLink detects URL and PhoneNumbers!](http://stackoverflow.com/questions/5965844/nsdatadetector-with-nstextcheckingtypelink-detects-url-and-phonenumbers). You want to pull out all the URLs and then filter on the URL scheme. –  Apr 04 '13 at 21:09

1 Answers1

1

Well, email addresses are not URLs. mailto:someone@some.where.com is a URL which contains an email address. So, to answer your question: Check whether your URL begins with mailto:. If it does, ignore it. If for some reason you're picking up email addresses as URLs, you probably have some parsing bug...

See here about regular expressions for URLs.

Community
  • 1
  • 1
einpoklum
  • 86,754
  • 39
  • 223
  • 453
  • Data detectors were created specifically to detect things like emial addresses that aren't in URL form. – Jon Shier Apr 04 '13 at 19:38
  • @jshier: I'm not much of an iOS developer, but [this](https://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSDataDetector_Class/Reference/Reference.html) says they're used for URLs also. – einpoklum Apr 04 '13 at 19:50