Skip to content

Commit

Permalink
fix bug casting from NSRange to Rnage when String.characters.count !=…
Browse files Browse the repository at this point in the history
… NSString.length
  • Loading branch information
cezheng committed Feb 22, 2016
1 parent 78aa500 commit 518590c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions PySwiftyRegex/PySwiftyRegex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ public class re {
if nsrange.location == NSNotFound {
return string.endIndex..<string.endIndex
}
let startIndex = string.startIndex.advancedBy(nsrange.location)
let endIndex = startIndex.advancedBy(nsrange.length)
return startIndex..<endIndex
let startIndex16 = string.utf16.startIndex.advancedBy(nsrange.location)
let endIndex16 = startIndex16.advancedBy(nsrange.length)
return (String.Index(startIndex16, within: string) ?? string.endIndex)..<(String.Index(endIndex16, within: string) ?? string.endIndex)
}
}
}

0 comments on commit 518590c

Please sign in to comment.