@@ -23,18 +23,18 @@ internal extension String {
23
23
24
24
func findAll( _ regex: String , flags: NSRegularExpression . Options ) -> [ String ] {
25
25
let re = try ! NSRegularExpression ( pattern: regex, options: flags)
26
- let all = NSMakeRange ( 0 , self . characters . count)
26
+ let all = NSMakeRange ( 0 , self . count)
27
27
let matches = re. matches ( in: self , options: [ ] , range: all)
28
28
return matches. map { self [ $0. range ( at: 1 ) ] . strip ( ) }
29
29
}
30
30
31
31
func split( ) -> [ String ] {
32
- return self . characters . split ( whereSeparator: { $0 == " " || $0 == " \n " } ) . map ( String . init)
32
+ return self . split ( whereSeparator: { $0 == " " || $0 == " \n " } ) . map ( String . init)
33
33
}
34
34
35
35
func split( _ regex: String ) -> [ String ] {
36
36
let re = try ! NSRegularExpression ( pattern: regex, options: . dotMatchesLineSeparators)
37
- let all = NSMakeRange ( 0 , self . characters . count)
37
+ let all = NSMakeRange ( 0 , self . count)
38
38
var result = [ String] ( )
39
39
let matches = re. matches ( in: self , options: [ ] , range: all)
40
40
if matches. count > 0 {
@@ -52,7 +52,7 @@ internal extension String {
52
52
53
53
result. append ( self [ range] )
54
54
lastEnd = range. location + range. length
55
- if lastEnd == self . characters . count {
55
+ if lastEnd == self . count {
56
56
// from python docs: If there are capturing groups in the separator and it matches at the start of the string,
57
57
// the result will start with an empty string. The same holds for the end of the string:
58
58
result. append ( " " )
@@ -62,8 +62,8 @@ internal extension String {
62
62
lastEnd = match. range. location + match. range. length
63
63
}
64
64
}
65
- if lastEnd != self . characters . count {
66
- result. append ( self [ lastEnd..< self . characters . count] )
65
+ if lastEnd != self . count {
66
+ result. append ( self [ lastEnd..< self . count] )
67
67
}
68
68
return result
69
69
}
@@ -77,7 +77,7 @@ internal extension String {
77
77
}
78
78
79
79
subscript( range: Range < Int > ) -> String {
80
- return String ( self [ characters . index ( startIndex, offsetBy: range. lowerBound) ..< characters . index ( startIndex, offsetBy: range. upperBound) ] )
80
+ return String ( self [ self . index ( startIndex, offsetBy: range. lowerBound) ..< self . index ( startIndex, offsetBy: range. upperBound) ] )
81
81
}
82
82
83
83
subscript( range: NSRange ) -> String {
0 commit comments