Skip to content

Commit 188ed6c

Browse files
committed
Merge branch 'pr/335'
2 parents a1ee6d1 + 10065fb commit 188ed6c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Foundation/NSRegularExpression.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ internal func _NSRegularExpressionMatch(_ context: UnsafeMutablePointer<Void>?,
140140

141141
extension NSRegularExpression {
142142

143-
/* The fundamental matching method on NSRegularExpression is a block iterator. There are several additional convenience methods, for returning all matches at once, the number of matches, the first match, or the range of the first match. Each match is specified by an instance of NSTextCheckingResult (of type NSTextCheckingTypeRegularExpression) in which the overall match range is given by the range property (equivalent to rangeAtIndex:0) and any capture group ranges are given by rangeAtIndex: for indexes from 1 to numberOfCaptureGroups. {NSNotFound, 0} is used if a particular capture group does not participate in the match.
143+
/* The fundamental matching method on NSRegularExpression is a block iterator. There are several additional convenience methods, for returning all matches at once, the number of matches, the first match, or the range of the first match. Each match is specified by an instance of NSTextCheckingResult (of type NSTextCheckingTypeRegularExpression) in which the overall match range is given by the range property (equivalent to range at:0) and any capture group ranges are given by range at: for indexes from 1 to numberOfCaptureGroups. {NSNotFound, 0} is used if a particular capture group does not participate in the match.
144144
*/
145145

146146
public func enumerateMatches(in string: String, options: NSMatchingOptions, range: NSRange, using block: (NSTextCheckingResult?, NSMatchingFlags, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
@@ -300,7 +300,7 @@ extension NSRegularExpression {
300300
var substringRange = NSMakeRange(NSNotFound, 0)
301301
var substring = ""
302302
if groupNumber < numberOfRanges {
303-
substringRange = result.rangeAtIndex(groupNumber)
303+
substringRange = result.range(at: groupNumber)
304304
}
305305
if substringRange.location != NSNotFound {
306306
substringRange.location += offset

Foundation/NSTextCheckingResult.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public class NSTextCheckingResult : NSObject, NSCopying, NSCoding {
4545

4646
/* Mandatory properties, used with all types of results. */
4747
public var resultType: NSTextCheckingType { NSUnimplemented() }
48-
public var range: NSRange { return rangeAtIndex(0) }
48+
public var range: NSRange { return range(at: 0) }
4949
/* A result must have at least one range, but may optionally have more (for example, to represent regular expression capture groups). The range at index 0 always matches the range property. Additional ranges, if any, will have indexes from 1 to numberOfRanges-1. */
50-
public func rangeAtIndex(_ idx: Int) -> NSRange { NSUnimplemented() }
50+
public func range(at idx: Int) -> NSRange { NSUnimplemented() }
5151
public var regularExpression: NSRegularExpression? { return nil }
5252
public var numberOfRanges: Int { return 1 }
5353
}
@@ -69,7 +69,7 @@ internal class _NSRegularExpressionTextCheckingResultResult : NSTextCheckingResu
6969
}
7070

7171
override var resultType: NSTextCheckingType { return .RegularExpression }
72-
override func rangeAtIndex(_ idx: Int) -> NSRange { return _ranges[idx] }
72+
override func range(at idx: Int) -> NSRange { return _ranges[idx] }
7373
override var numberOfRanges: Int { return _ranges.count }
7474
override var regularExpression: NSRegularExpression? { return _regularExpression }
7575
}

TestFoundation/TestNSRegularExpression.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ class TestNSRegularExpression : XCTestCase {
221221
if let first = firstResult where matches.count > 0 {
222222
XCTAssertTrue(NSEqualRanges(first.range, firstMatchOverallRange), "Complex regex \(patternString) in \(searchString) match range \(NSStringFromRange(first.range)) should be \(NSStringFromRange(firstMatchOverallRange))", file: file, line: line)
223223
if captureCount > 0 {
224-
XCTAssertTrue(NSEqualRanges(first.rangeAtIndex(1), firstMatchFirstCaptureRange), "Complex regex \(patternString) in \(searchString) match range \(first.rangeAtIndex(1)) should be \(NSStringFromRange(firstMatchFirstCaptureRange))", file: file, line: line)
224+
XCTAssertTrue(NSEqualRanges(first.range(at: 1), firstMatchFirstCaptureRange), "Complex regex \(patternString) in \(searchString) match range \(first.range(at: 1)) should be \(NSStringFromRange(firstMatchFirstCaptureRange))", file: file, line: line)
225225
} else {
226226
XCTAssertTrue(NSEqualRanges(firstMatchFirstCaptureRange, NSMakeRange(NSNotFound, 0)), "Complex regex \(patternString) in \(searchString) no captures should be \(NSStringFromRange(firstMatchFirstCaptureRange))", file: file, line: line)
227227
}
228228
if captureCount > 1 {
229-
XCTAssertTrue(NSEqualRanges(first.rangeAtIndex(captureCount), firstMatchLastCaptureRange), "Complex regex \(patternString) in \(searchString) last capture range \(NSStringFromRange(first.rangeAtIndex(captureCount))) should be \(NSStringFromRange(firstMatchLastCaptureRange))", file: file, line: line)
229+
XCTAssertTrue(NSEqualRanges(first.range(at: captureCount), firstMatchLastCaptureRange), "Complex regex \(patternString) in \(searchString) last capture range \(NSStringFromRange(first.range(at: captureCount))) should be \(NSStringFromRange(firstMatchLastCaptureRange))", file: file, line: line)
230230
}
231231
}
232232
} catch {

0 commit comments

Comments
 (0)