Reputation: 829
I have a NSURL
NSURL* url = [NSURL URLWithString:@"http://www.google.com"];
I want to get the "google" from this string , How can i do that?
Upvotes: 2
Views: 2974
Reputation: 11530
You can get just the domain part with this:
[url host]
...will get you www.google.com
, then you'll need to do some regex/string replacement to strip off the www.
and .com
parts.
I'd suggest a regex something like the following:
\.?(.+)\.([a-z]{2,})$
...then pull out that first match for the part you want.
Upvotes: 6