NSString
-
Function to return an array of
NSRanges forsubstringinself. Searches the string from index 0, soranges(of: ).firstwill be the firstNSRangein the string. Note this is returning anNSRange, not a SwiftRange. See http://stackoverflow.com/a/27041376/2580195 for why these two types of ranges are incompatible.If you only need the first range, and not as
NSRange, use Swift’srange(of: ).Declaration
Swift
public func ranges(of searchString: String, options mask: NSString.CompareOptions = [NSString.CompareOptions.caseInsensitive]) -> [NSRange]Parameters
searchStringSubstring to find.
maskNSString.CompareOptions, defaults toNSString.CompareOptions.caseInsensitive.Return Value
Array of
NSRanges wheresearchStringis inself.
NSString Extension Reference