How to write regular expressions in Objective C (NSRegularExpression)?
A NSTextCheckingResult has multiple items obtained by indexing into it. [match rangeAtIndex:0]; is the full match. [match rangeAtIndex:1]; (if it exists) is the first capture group match. etc. You can use something like this: NSString *searchedString = @”domain-name.tld.tld2″; NSRange searchedRange = NSMakeRange(0, [searchedString length]); NSString *pattern = @”(?:www\\.)?((?!-)[a-zA-Z0-9-]{2,63}(?<!-))\\.?((?:[a-zA-Z0-9]{2,})?(?:\\.[a-zA-Z0-9]{2,})?)”; NSError *error = nil; NSRegularExpression* regex = … Read more