NSString
-
Function to return an array of
NSRange
s forsubstring
inself
. Searches the string from index 0, soranges(of: ).first
will be the firstNSRange
in 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
searchString
Substring to find.
mask
NSString.CompareOptions
, defaults toNSString.CompareOptions.caseInsensitive
.Return Value
Array of
NSRange
s wheresearchString
is inself
.